From 7e867ad61f4938f63f3f4f04332a01d4cf17ba49 Mon Sep 17 00:00:00 2001 From: senhuang42 Date: Wed, 26 Aug 2020 18:52:32 -0400 Subject: [PATCH] Fix potential memory leak --- programs/fileio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index c982bda9..3eaa0455 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -1722,8 +1722,10 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs, /* init */ assert(outFileName != NULL || suffix != NULL); if (outFileName != NULL) { /* output into a single destination (stdout typically) */ - if (FIO_removeMultiFilesWarning(prefs, 1 /* displayLevelCutoff */, outFileName)) + if (FIO_removeMultiFilesWarning(prefs, 1 /* displayLevelCutoff */, outFileName)) { + FIO_freeCResources(ress); return 1; + } ress.dstFile = FIO_openDstFile(prefs, NULL, outFileName); if (ress.dstFile == NULL) { /* could not open outFileName */ error = 1; @@ -2618,8 +2620,10 @@ FIO_decompressMultipleFilenames(FIO_prefs_t* const prefs, dRess_t ress = FIO_createDResources(prefs, dictFileName); if (outFileName) { - if (FIO_removeMultiFilesWarning(prefs, 1 /* displayLevelCutoff */, outFileName)) + if (FIO_removeMultiFilesWarning(prefs, 1 /* displayLevelCutoff */, outFileName)) { + FIO_freeDResources(ress); return 1; + } if (!prefs->testMode) { ress.dstFile = FIO_openDstFile(prefs, NULL, outFileName); if (ress.dstFile == 0) EXM_THROW(19, "cannot open %s", outFileName);