Browse Source

lib/fs: Avoid dirty offset read in fakefs (fixes #6584)

Jakob Borg 5 years ago
parent
commit
0e2a07d71a
1 changed files with 4 additions and 1 deletions
  1. 4 1
      lib/fs/fakefs.go

+ 4 - 1
lib/fs/fakefs.go

@@ -754,7 +754,10 @@ func (f *fakeFile) Seek(offset int64, whence int) (int64, error) {
 }
 
 func (f *fakeFile) Write(p []byte) (int, error) {
-	return f.WriteAt(p, f.offset)
+	f.mut.Lock()
+	offs := f.offset
+	f.mut.Unlock()
+	return f.WriteAt(p, offs)
 }
 
 func (f *fakeFile) WriteAt(p []byte, off int64) (int, error) {