ref: df02b007883fa6554f5389e8f0ad8ef3917824ba
parent: fe74073efef1616f573afd8c4c926ecbd66d0d72
author: robs <robs>
date: Tue Dec 19 15:02:17 EST 2006
Fix cleanup for ST_FILE_NOSTDIO.
--- a/src/sox.c
+++ b/src/sox.c
@@ -193,19 +193,20 @@
}
if (writing && file_desc[file_count - 1]) {
- char *fn;
- struct stat st;
+ if (!(file_desc[file_count - 1]->h->flags & ST_FILE_NOSTDIO)) {
+ char *fn;
+ struct stat st;
- fstat(fileno(file_desc[file_count - 1]->fp), &st);
- fn = strdup(file_desc[file_count - 1]->filename);
- st_close(file_desc[file_count - 1]);
-
- /* If we didn't succeed, Remove the output file, if we created it. */
- if (!success && (st.st_mode & S_IFMT) == S_IFREG)
- unlink(fn);
- free(fn);
- if (file_desc[file_count - 1])
- free(file_desc[file_count - 1]);
+ fstat(fileno(file_desc[file_count - 1]->fp), &st);
+ fn = strdup(file_desc[file_count - 1]->filename);
+ st_close(file_desc[file_count - 1]);
+
+ /* If we didn't succeed, Remove the output file, if we created it. */
+ if (!success && (st.st_mode & S_IFMT) == S_IFREG)
+ unlink(fn);
+ free(fn);
+ }
+ free(file_desc[file_count - 1]);
}
}