From 82f5984de121716fa4c8c446f9edec5e17f79d76 Mon Sep 17 00:00:00 2001 From: "Star.LI" Date: Tue, 1 Sep 2020 17:22:53 +0800 Subject: [PATCH] fix crash - segment fault when partialFile.Allocated() is invoked. When openPartialFile is invoked, more errors than "existed error" are returned. If only existing error is checked, the allocated field of partialFile may be nil. Signed-off-by: Star.LI --- extern/sector-storage/ffiwrapper/sealer_cgo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/sector-storage/ffiwrapper/sealer_cgo.go b/extern/sector-storage/ffiwrapper/sealer_cgo.go index a72f5a66f..c4e5511d1 100644 --- a/extern/sector-storage/ffiwrapper/sealer_cgo.go +++ b/extern/sector-storage/ffiwrapper/sealer_cgo.go @@ -371,7 +371,7 @@ func (sb *Sealer) ReadPiece(ctx context.Context, writer io.Writer, sector abi.Se maxPieceSize := abi.PaddedPieceSize(sb.ssize) pf, err := openPartialFile(maxPieceSize, path.Unsealed) - if xerrors.Is(err, os.ErrNotExist) { + if err != nil { return false, xerrors.Errorf("opening partial file: %w", err) }