png: fix video state leaks
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 7 Jun 2012 10:16:50 +0000 (11:16 +0100)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 7 Jun 2012 10:25:23 +0000 (11:25 +0100)
ext/libpng/gstpngdec.c
ext/libpng/gstpngenc.c

index 7c4d558fbc49c4feaa1b64c0a9ce8bdbf027dae8..a9c3a32b76e65b7443515310cbcf3e6bbe6c99e2 100644 (file)
@@ -508,5 +508,14 @@ gst_pngdec_stop (GstVideoDecoder * decoder)
 
   pngdec->color_type = -1;
 
+  if (pngdec->input_state) {
+    gst_video_codec_state_unref (pngdec->input_state);
+    pngdec->input_state = NULL;
+  }
+  if (pngdec->output_state) {
+    gst_video_codec_state_unref (pngdec->output_state);
+    pngdec->output_state = NULL;
+  }
+
   return TRUE;
 }
index f8dcff4dd96d3814a27aaff1ef5a655d9633670c..9d3e1d046b99065aa0bc893b71704fb0430d0b58 100644 (file)
@@ -85,6 +85,8 @@ static gboolean gst_pngenc_set_format (GstVideoEncoder * encoder,
 static gboolean gst_pngenc_propose_allocation (GstVideoEncoder * encoder,
     GstQuery * query);
 
+static void gst_pngenc_finalize (GObject * object);
+
 static void
 user_error_fn (png_structp png_ptr, png_const_charp error_msg)
 {
@@ -137,6 +139,7 @@ gst_pngenc_class_init (GstPngEncClass * klass)
   venc_class->set_format = gst_pngenc_set_format;
   venc_class->handle_frame = gst_pngenc_handle_frame;
   venc_class->propose_allocation = gst_pngenc_propose_allocation;
+  gobject_class->finalize = gst_pngenc_finalize;
 
   GST_DEBUG_CATEGORY_INIT (pngenc_debug, "pngenc", 0, "PNG image encoder");
 }
@@ -203,6 +206,17 @@ gst_pngenc_init (GstPngEnc * pngenc)
   pngenc->compression_level = DEFAULT_COMPRESSION_LEVEL;
 }
 
+static void
+gst_pngenc_finalize (GObject * object)
+{
+  GstPngEnc *pngenc = GST_PNGENC (object);
+
+  if (pngenc->input_state)
+    gst_video_codec_state_unref (pngenc->input_state);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
 static void
 user_flush_data (png_structp png_ptr G_GNUC_UNUSED)
 {