audioencoder: plug a definite and rare leak
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 4 Apr 2012 17:43:32 +0000 (19:43 +0200)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 4 Apr 2012 17:57:35 +0000 (19:57 +0200)
gst-libs/gst/audio/gstaudioencoder.c

index 1780de4..add902e 100644 (file)
@@ -439,14 +439,15 @@ gst_audio_encoder_reset (GstAudioEncoder * enc, gboolean full)
     enc->priv->active = FALSE;
     enc->priv->samples_in = 0;
     enc->priv->bytes_out = 0;
-    gst_audio_info_init (&enc->priv->ctx.info);
-    memset (&enc->priv->ctx, 0, sizeof (enc->priv->ctx));
 
     g_list_foreach (enc->priv->ctx.headers, (GFunc) gst_buffer_unref, NULL);
     g_list_free (enc->priv->ctx.headers);
     enc->priv->ctx.headers = NULL;
     enc->priv->ctx.new_headers = FALSE;
 
+    memset (&enc->priv->ctx, 0, sizeof (enc->priv->ctx));
+    gst_audio_info_init (&enc->priv->ctx.info);
+
     if (enc->priv->tags)
       gst_tag_list_free (enc->priv->tags);
     enc->priv->tags = NULL;
@@ -828,6 +829,8 @@ exit:
 no_caps:
   {
     GST_ELEMENT_ERROR (enc, STREAM, ENCODE, ("no caps set"), (NULL));
+    if (buf)
+      gst_buffer_unref (buf);
     return GST_FLOW_ERROR;
   }
 overflow: