plug a memleak
authorColin Walters <walters@verbum.org>
Fri, 30 Apr 2004 20:57:48 +0000 (20:57 +0000)
committerColin Walters <walters@verbum.org>
Fri, 30 Apr 2004 20:57:48 +0000 (20:57 +0000)
Original commit message from CVS:
plug a memleak

ChangeLog
ext/alsa/gstalsasink.c

index 2563d1cce52c44001f8bfdb155ded55cfc1da0f7..d1c685c426361aa422fa2379f397753f361873ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-04-30  Colin Walters  <walters@verbum.org>
+
+       * ext/alsa/gstalsasink.c (gst_alsa_sink_mmap): Plug a memleak.
+
 2004-04-30  Thomas Vander Stichele  <thomas at apestaart dot org>
 
        * gst/ffmpegcolorspace/gstffmpegcolorspace.c:
index 2fd4e572f5f7bdca83c393bc1f6882fbbdf63217..7ff037b1c937ac99e51eb35d9fd6ca1e98201d36 100644 (file)
@@ -254,7 +254,9 @@ gst_alsa_sink_mmap (GstAlsa * this, snd_pcm_sframes_t * avail)
   const snd_pcm_channel_area_t *dst;
   snd_pcm_channel_area_t *src;
   GstAlsaSink *sink = GST_ALSA_SINK (this);
-  int i, err, width = snd_pcm_format_physical_width (this->format->format);
+  int i;
+  int err = -1;
+  int width = snd_pcm_format_physical_width (this->format->format);
 
   /* areas points to the memory areas that belong to gstreamer. */
   src = g_malloc0 (this->format->channels * sizeof (snd_pcm_channel_area_t));
@@ -277,7 +279,7 @@ gst_alsa_sink_mmap (GstAlsa * this, snd_pcm_sframes_t * avail)
 
   if ((err = snd_pcm_mmap_begin (this->handle, &dst, &offset, avail)) < 0) {
     GST_ERROR_OBJECT (this, "mmap failed: %s", snd_strerror (err));
-    return -1;
+    goto out;
   }
 
   if ((err =
@@ -285,13 +287,15 @@ gst_alsa_sink_mmap (GstAlsa * this, snd_pcm_sframes_t * avail)
               *avail, this->format->format)) < 0) {
     snd_pcm_mmap_commit (this->handle, offset, 0);
     GST_ERROR_OBJECT (this, "data copy failed: %s", snd_strerror (err));
-    return -1;
+    goto out;
   }
   if ((err = snd_pcm_mmap_commit (this->handle, offset, *avail)) < 0) {
     GST_ERROR_OBJECT (this, "mmap commit failed: %s", snd_strerror (err));
-    return -1;
+    goto out;
   }
 
+ out:
+  g_free (src);
   return err;
 }
 static int