shithub: sox

Download patch

ref: 33d42fb2e16d6bbcb17f57fe52f508a208098bae
parent: d37d609371b1aeba86c071cfff14b66f4fd5438b
author: cbagwell <cbagwell>
date: Sun Aug 29 22:45:23 EDT 2004

Fixes to comment memory leaks.

--- a/src/sox.c
+++ b/src/sox.c
@@ -311,12 +311,6 @@
         st_fail("Unknown input file format for '%s':  %s", 
                 ft->filename, ft->st_errstr);
 
-    /* Default the input comment to the filename if not set from
-     * command line.
-     */
-    if (!ft->comment)
-        ft->comment = strdup(ft->filename);
-
     input_count++;
 }
 
@@ -815,6 +809,7 @@
         if ((* informat[f]->h->stopread)(informat[f]) == ST_EOF)
             st_warn(informat[f]->st_errstr);
         fclose(informat[f]->fp);
+        free(informat[f]->filename);
     }
 
     if (writing)
@@ -822,8 +817,10 @@
         /* problem closing output file, just warn user since we
          * are exiting anyways.
          */
-        if ((* outformat->h->stopwrite)(outformat) == ST_EOF)
+        if ((*outformat->h->stopwrite)(outformat) == ST_EOF)
             st_warn(outformat->st_errstr);
+        free(outformat->filename);
+        free(outformat->comment);
     }
     if (writing)
         fclose(outformat->fp);
--- a/src/util.c
+++ b/src/util.c
@@ -363,6 +363,8 @@
 
     if (ft2->comment == NULL && ft->comment != NULL)
         ft2->comment = strdup(ft->comment);
+    else
+        ft2->comment = strdup("Processed by SoX");
 
     /*
      * copy loop info, resizing appropriately