]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Release resources before returning 4401/head
authorjinyaoguo <guo846@purdue.edu>
Tue, 3 Jun 2025 19:28:11 +0000 (15:28 -0400)
committerjinyaoguo <guo846@purdue.edu>
Tue, 3 Jun 2025 19:28:11 +0000 (15:28 -0400)
In main, resources were freed on the success path but not in the error path.
This change ensures all allocated resources are released before returning.

contrib/externalSequenceProducer/main.c

index e67e295383c25bfd2c4e2a386da170ae3aa65850..c81e9bf409796c1232890a4d5775be3e8d60ae1a 100644 (file)
@@ -27,6 +27,7 @@ do {                                                    \
 } while (0)                                             \
 
 int main(int argc, char *argv[]) {
+    int retn = 0;
     if (argc != 2) {
         printf("Usage: externalSequenceProducer <file>\n");
         return 1;
@@ -96,12 +97,12 @@ int main(int argc, char *argv[]) {
                 break;
             }
         }
-        return 1;
+        retn = 1;
     }
 
     ZSTD_freeCCtx(zc);
     free(src);
     free(dst);
     free(val);
-    return 0;
+    return retn;
 }