From d175ebcca832db55ae2eb9659294ba0d91a5996e Mon Sep 17 00:00:00 2001 From: Rafal Zajac Date: Fri, 13 Nov 2020 22:59:22 +0100 Subject: [PATCH] mem.File.Truncate should use lock Fixes: #272 --- mem/file.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mem/file.go b/mem/file.go index 07b2e12..122d77c 100644 --- a/mem/file.go +++ b/mem/file.go @@ -210,6 +210,8 @@ func (f *File) Truncate(size int64) error { if size < 0 { return ErrOutOfRange } + f.fileData.Lock() + defer f.fileData.Unlock() if size > int64(len(f.fileData.data)) { diff := size - int64(len(f.fileData.data)) f.fileData.data = append(f.fileData.data, bytes.Repeat([]byte{00}, int(diff))...)