shithub: sox

Download patch

ref: 55b87114e673804420fe5f55c55a9fbc8f0294b4
parent: ab4d77c74ae5c31c384f8386f8527eb5506d7b32
author: robs <robs>
date: Mon Nov 27 09:46:28 EST 2006

Stop crash when alsa is used as file extension.
Moved and corrected a check that was in the wrong place.

--- a/src/stio.c
+++ b/src/stio.c
@@ -104,7 +104,7 @@
     if (!ft->filename || !ft->filetype)
         goto input_error;
 
-    if (st_gettype(ft) != ST_SUCCESS)
+    if (st_gettype(ft, false) != ST_SUCCESS)
     {
         st_warn("Unknown input file format for '%s':  %s", 
                 ft->filename, 
@@ -188,6 +188,7 @@
 {
     ft_t ft;
     int i;
+    bool no_filetype_given = filetype == NULL;
 
     ft = (ft_t)calloc(sizeof(struct st_soundstream), 1);
 
@@ -196,6 +197,12 @@
 
     ft->filename = strdup(path);
 
+    if (!ft->filename)
+    {
+        st_fail_errno(ft,ST_ENOMEM,"st_open_write_instr");
+        goto output_error;
+    }
+
     /* Let auto effect do the work if user is not overriding. */
     if (!filetype)
     {
@@ -221,13 +228,7 @@
     else
         ft->filetype = strdup(filetype);
 
-    if (!ft->filename)
-    {
-        st_warn("Unknown output file format for 'NULL'.");
-        goto output_error;
-    }
-
-    if (!ft->filetype || st_gettype(ft) != ST_SUCCESS)
+    if (!ft->filetype || st_gettype(ft, no_filetype_given) != ST_SUCCESS)
     {
         st_warn("Unknown output file format for '%s':  %s", 
                 ft->filename,