diff --git a/programs/fileio.c b/programs/fileio.c index 2a7d73d1..c0ec891e 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -433,6 +433,10 @@ static int FIO_compressFilename_extRess(cRess_t ress, result = FIO_compressFilename_internal(ress, dstFileName, srcFileName, cLevel); + if (result != 0) { + remove(dstFileName); + } + fclose(ress.srcFile); /* no pb to expect : only reading */ if (fclose(ress.dstFile)) EXM_THROW(28, "Write error : cannot properly close %s", dstFileName); return result; @@ -638,13 +642,17 @@ static int FIO_decompressSrcFile(dRess_t ress, const char* srcFileName) static int FIO_decompressFile_extRess(dRess_t ress, const char* dstFileName, const char* srcFileName) { + int result; ress.dstFile = FIO_openDstFile(dstFileName); if (ress.dstFile==0) return 1; - FIO_decompressSrcFile(ress, srcFileName); + result = FIO_decompressSrcFile(ress, srcFileName); + if (result != 0) { + remove(dstFileName); + } if (fclose(ress.dstFile)) EXM_THROW(38, "Write error : cannot properly close %s", dstFileName); - return 0; + return result; } diff --git a/programs/playTests.sh b/programs/playTests.sh index ec625ee8..891ab9d4 100755 --- a/programs/playTests.sh +++ b/programs/playTests.sh @@ -36,7 +36,10 @@ $ZSTD --decompress tmpCompressed --stdout > tmpResult $ZSTD -q tmp && die "overwrite check failed!" $ZSTD -q -f tmp $ZSTD -q --force tmp - +$ZSTD -df tmp && die "should have refused : wrong extension" +cp tmp tmp2.zst +$ZSTD -df tmp2.zst && die "should have failed : wrong format" +rm tmp2.zst echo "\n**** frame concatenation **** "