From bd584e6b9288390efab079b75eb51107f6c4918a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 24 Feb 2006 12:18:14 +0000 Subject: [PATCH] gst/ffmpegcolorspace/gstffmpegcolorspace.c: Plug some memory leaks. Original commit message from CVS: * gst/ffmpegcolorspace/gstffmpegcolorspace.c: (gst_ffmpegcsp_transform_caps), (gst_ffmpegcsp_set_caps), (gst_ffmpegcsp_finalize), (gst_ffmpegcsp_class_init), (gst_ffmpegcsp_get_unit_size): Plug some memory leaks. --- ChangeLog | 8 ++++++++ gst/ffmpegcolorspace/gstffmpegcolorspace.c | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3fc4d687a4..981b84a5c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-02-24 Tim-Philipp Müller + + * gst/ffmpegcolorspace/gstffmpegcolorspace.c: + (gst_ffmpegcsp_transform_caps), (gst_ffmpegcsp_set_caps), + (gst_ffmpegcsp_finalize), (gst_ffmpegcsp_class_init), + (gst_ffmpegcsp_get_unit_size): + Plug some memory leaks. + 2006-02-24 Tim-Philipp Müller * sys/ximage/Makefile.am: diff --git a/gst/ffmpegcolorspace/gstffmpegcolorspace.c b/gst/ffmpegcolorspace/gstffmpegcolorspace.c index 3cf3cb8bdf..818a18f126 100644 --- a/gst/ffmpegcolorspace/gstffmpegcolorspace.c +++ b/gst/ffmpegcolorspace/gstffmpegcolorspace.c @@ -147,6 +147,7 @@ gst_ffmpegcsp_transform_caps (GstBaseTransform * btrans, template = gst_ffmpegcsp_codectype_to_caps (CODEC_TYPE_VIDEO, NULL); result = gst_caps_intersect (caps, template); + gst_caps_unref (template); gst_caps_append (result, gst_ffmpegcsp_caps_remove_format_info (caps)); @@ -231,6 +232,7 @@ gst_ffmpegcsp_set_caps (GstBaseTransform * btrans, GstCaps * incaps, if (space->palette) av_free (space->palette); space->palette = ctx->palctrl; + ctx->palctrl = NULL; /* get to format */ ctx->pix_fmt = PIX_FMT_NB; @@ -320,6 +322,17 @@ gst_ffmpegcsp_base_init (GstFFMpegCspClass * klass) gst_element_class_set_details (element_class, &ffmpegcsp_details); } +static void +gst_ffmpegcsp_finalize (GObject * obj) +{ + GstFFMpegCsp *space = GST_FFMPEGCSP (obj); + + if (space->palette) + av_free (space->palette); + + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + static void gst_ffmpegcsp_class_init (GstFFMpegCspClass * klass) { @@ -331,7 +344,9 @@ gst_ffmpegcsp_class_init (GstFFMpegCspClass * klass) gstelement_class = (GstElementClass *) klass; gstbasetransform_class = (GstBaseTransformClass *) klass; - parent_class = g_type_class_ref (GST_TYPE_BASE_TRANSFORM); + parent_class = g_type_class_peek_parent (klass); + + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_ffmpegcsp_finalize); gstbasetransform_class->transform_caps = GST_DEBUG_FUNCPTR (gst_ffmpegcsp_transform_caps); @@ -386,6 +401,8 @@ gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, if (space->palette) *size -= 4 * 256; + if (ctx->palctrl) + av_free (ctx->palctrl); av_free (ctx); return TRUE;