playback,videoscale: fix caps leak
authorEunhae Choi <eunhae1.choi@samsung.com>
Thu, 29 Jun 2017 11:14:21 +0000 (20:14 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Thu, 29 Jun 2017 11:14:21 +0000 (20:14 +0900)
Change-Id: I7b560c0c4ec9de84f9db1e0fee2e8f3b14a70040

gst/playback/gstplaybackutils.c
gst/videoscale/gstvideoscale.c

index d003c91..5555573 100644 (file)
@@ -81,6 +81,9 @@ gst_playback_utils_get_n_common_capsfeatures (GstElementFactory * fact1,
   fact1_tmpl_caps = get_template_caps (fact1, GST_PAD_SRC);
   fact2_tmpl_caps = get_template_caps (fact2, GST_PAD_SINK);
   if (!fact1_tmpl_caps || !fact2_tmpl_caps) {
+    if (fact1_tmpl_caps) gst_caps_unref (fact1_tmpl_caps);
+    if (fact2_tmpl_caps) gst_caps_unref (fact2_tmpl_caps);
+
     GST_ERROR ("Failed to get template caps from decoder or sink");
     return 0;
   }
@@ -128,6 +131,7 @@ gst_playback_utils_get_n_common_capsfeatures (GstElementFactory * fact1,
 
   gst_caps_unref (fact1_tmpl_caps);
   gst_caps_unref (fact2_tmpl_caps);
+  gst_caps_unref (raw_caps);
 
   return n_common_cf;
 }
index 871717b..64bee0e 100644 (file)
@@ -166,15 +166,19 @@ gst_video_scale_get_capslist (void)
 static GstPadTemplate *
 gst_video_scale_src_template_factory (void)
 {
-  return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
-      gst_video_scale_get_capslist ());
+  GstCaps *tmp = gst_video_scale_get_capslist ();
+  GstPadTemplate *tmpl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, tmp);
+  gst_caps_unref (tmp);
+  return tmpl;
 }
 
 static GstPadTemplate *
 gst_video_scale_sink_template_factory (void)
 {
-  return gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
-      gst_video_scale_get_capslist ());
+  GstCaps *tmp = gst_video_scale_get_capslist ();
+  GstPadTemplate *tmpl = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, tmp);
+  gst_caps_unref (tmp);
+  return tmpl;
 }