shithub: sox

Download patch

ref: 56548b1abc4de9d3eb73aea90f4384f5021f7acb
parent: d413c73ca2c43f879fa14afd5cc3186a7c4d8dd5
author: cbagwell <cbagwell>
date: Sun Mar 11 23:29:33 EST 2001

Fixing cleanup code.  Could access invalid pointer.

--- a/src/avg.c
+++ b/src/avg.c
@@ -20,6 +20,7 @@
 
 #include "st.h"
 #include <ctype.h>
+#include <string.h>
 
 /* Private data for SKEL file */
 typedef struct avgstuff {
--- a/src/band.c
+++ b/src/band.c
@@ -44,6 +44,7 @@
  */
 
 #include <math.h>
+#include <string.h>
 #include "st.h"
 
 /* Private data for Bandpass effect */
--- a/src/ima_rw.c
+++ b/src/ima_rw.c
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 #include <math.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include "ima_rw.h"
 
 /*
--- a/src/sox.c
+++ b/src/sox.c
@@ -997,9 +997,9 @@
 /* called from util.c:fail */
 void cleanup(void) {
 	/* Close the input file and outputfile before exiting*/
-	if (informat->fp)
+	if (informat && informat->fp)
 		fclose(informat->fp);
-	if (outformat->fp) {
+	if (outformat && outformat->fp) {
 		fclose(outformat->fp);
 		/* remove the output file because we failed, if it's ours. */
 		/* Don't if its not a regular file. */
--- a/src/stat.c
+++ b/src/stat.c
@@ -17,6 +17,7 @@
  */
 
 #include <math.h>
+#include <string.h>
 #include "st.h"
 
 /* Private data for STAT effect */