[xiph-cvs] cvs commit: ao/src audio_out.c

Stan Seibert volsung at xiph.org
Tue Aug 26 13:14:58 PDT 2003



volsung     03/08/26 16:14:58

  Modified:    src      audio_out.c
  Log:
  Close a memory leak and do more paranoid checking.  Closes bug 258.

Revision  Changes    Path
1.25      +19 -3     ao/src/audio_out.c

Index: audio_out.c
===================================================================
RCS file: /usr/local/cvsroot/ao/src/audio_out.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- audio_out.c	14 Jul 2003 01:55:46 -0000	1.24
+++ audio_out.c	26 Aug 2003 20:14:58 -0000	1.25
@@ -662,6 +662,9 @@
 {
         char *playback_buffer;
 
+	if (device == NULL)
+	  return 0;
+
         if (device->swap_buffer != NULL) {
                 if (_realloc_swap_buffer(device, num_bytes)) {
                         _swap_samples(device->swap_buffer, 
@@ -680,9 +683,22 @@
 {
         int result;
 
-	result = device->funcs->close(device);
-	device->funcs->device_clear(device);
-	free(device);
+	if (device == NULL)
+		result = 0;
+	else {
+		result = device->funcs->close(device);
+		device->funcs->device_clear(device);
+
+		if (device->file) {
+			fclose(device->file);
+			device->file = NULL;
+		}
+
+		if (device->swap_buffer != NULL)
+			free(device->swap_buffer);
+
+		free(device);
+	}
 
         return result;
 }

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list