From d0d062e9ae43e5e52da26b2de1eed6a06a3def03 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 30 Apr 2004 20:57:48 +0000 Subject: [PATCH] plug a memleak Original commit message from CVS: plug a memleak --- ChangeLog | 4 ++++ ext/alsa/gstalsasink.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2563d1cce5..d1c685c426 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-04-30 Colin Walters + + * ext/alsa/gstalsasink.c (gst_alsa_sink_mmap): Plug a memleak. + 2004-04-30 Thomas Vander Stichele * gst/ffmpegcolorspace/gstffmpegcolorspace.c: diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c index 2fd4e572f5..7ff037b1c9 100644 --- a/ext/alsa/gstalsasink.c +++ b/ext/alsa/gstalsasink.c @@ -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