changeset 9156:a75cab40c985

double free(), found by Olivier Galibert <galibert@pobox.com>
author arpi
date Wed, 29 Jan 2003 12:22:00 +0000
parents d49d15271b99
children 5a034ae2a27f
files libao2/ao_pcm.c
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_pcm.c	Wed Jan 29 12:16:18 2003 +0000
+++ b/libao2/ao_pcm.c	Wed Jan 29 12:22:00 2003 +0000
@@ -77,9 +77,7 @@
 static int init(int rate,int channels,int format,int flags){
 	int bits;
 	if(!ao_outputfilename) {
-		ao_outputfilename = (char *) malloc(sizeof(char) * 14);
-		strcpy(ao_outputfilename,
-		       (ao_pcm_waveheader ? "audiodump.wav" : "audiodump.pcm"));
+		ao_outputfilename = strdup(ao_pcm_waveheader ? "audiodump.wav" : "audiodump.pcm");
 	}
 
 	/* bits is only equal to format if (format == 8) or (format == 16);
@@ -138,7 +136,6 @@
 		fwrite(&wavhdr,sizeof(wavhdr),1,fp);
 	}
 	fclose(fp);
-	free(ao_outputfilename);
 }
 
 // stop playing and empty buffers (for seeking/pause)