rtph265depay : fix mem leak
authorEunhae Choi <eunhae1.choi@samsung.com>
Mon, 19 Jun 2017 01:55:58 +0000 (10:55 +0900)
committereunhae choi <eunhae1.choi@samsung.com>
Mon, 19 Jun 2017 12:46:31 +0000 (12:46 +0000)
Change-Id: I6ed5269baca45d8ef2b11aa0647a65a72f33100f

ext/directfb/dfbvideosink.c
gst/rtp/gstrtph265depay.c

index 900c6b1..f9dbb60 100644 (file)
@@ -37,7 +37,7 @@
  *   This mode handles navigation events for every input device supported by
  *   the <ulink url="http://www.directfb.org/">DirectFB</ulink> library, it will
  *   look for available video modes in the fb.modes file and try to switch
- *   the framebuffer video mode to the most suitable one. Depending on 
+ *   the framebuffer video mode to the most suitable one. Depending on
  *   hardware acceleration capabilities the element will handle scaling or not.
  *   If no acceleration is available it will do clipping or centering of the
  *   video frames respecting the original aspect ratio.
  * </listitem>
  * <listitem>
  *   <para>
- *   Embedded: this mode will render video frames in a 
+ *   Embedded: this mode will render video frames in a
  *   #GstDfbVideoSink:surface provided by the
  *   application developer. This is a more advanced usage of the element and
- *   it is required to integrate video playback in existing 
+ *   it is required to integrate video playback in existing
  *   <ulink url="http://www.directfb.org/">DirectFB</ulink> applications.
  *   </para>
  *   <para>
  *   When using this mode the element just renders to the
- *   #GstDfbVideoSink:surface provided by the 
+ *   #GstDfbVideoSink:surface provided by the
  *   application, that means it won't handle navigation events and won't resize
  *   the #GstDfbVideoSink:surface to fit video
  *   frames geometry. Application has to implement the necessary code to grab
@@ -62,8 +62,8 @@
  *   </para>
  * </listitem>
  * </itemizedlist>
- * For both modes the element implements a buffer pool allocation system to 
- * optimize memory allocation time and handle reverse negotiation. Indeed if 
+ * For both modes the element implements a buffer pool allocation system to
+ * optimize memory allocation time and handle reverse negotiation. Indeed if
  * you insert an element like videoscale in the pipeline the video sink will
  * negotiate with it to try get a scaled video for either the fullscreen layout
  * or the application provided external #GstDfbVideoSink:surface.
@@ -796,7 +796,7 @@ gst_dfbvideosink_setup (GstDfbVideoSink * dfbvideosink)
   dfbvideosink->backbuffer = FALSE;
   dfbvideosink->pixel_format = DSPF_UNKNOWN;
 
-  /* If we do it all by ourself we create the DirectFB context, get the 
+  /* If we do it all by ourself we create the DirectFB context, get the
      primary layer and use a fullscreen configuration */
   if (!dfbvideosink->ext_surface) {
     GST_DEBUG_OBJECT (dfbvideosink, "no external surface, taking over "
index bfc2e13..55615b7 100644 (file)
@@ -320,6 +320,7 @@ static gboolean
 gst_rtp_h265_set_src_caps (GstRtpH265Depay * rtph265depay)
 {
   gboolean res;
+  GstCaps *old_caps;
   GstCaps *srccaps;
 
   if (!rtph265depay->byte_stream &&
@@ -531,9 +532,9 @@ gst_rtp_h265_set_src_caps (GstRtpH265Depay * rtph265depay)
     gst_buffer_unref (codec_data);
   }
 
-  if (gst_pad_has_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph265depay))) {
-    GstCaps *old_caps =
-        gst_pad_get_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph265depay));
+  old_caps =
+      gst_pad_get_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph265depay));
+  if (old_caps != NULL) {
 
     /* Only update the caps if they are not equal. For
      * AVC we don't update caps if only the codec_data
@@ -566,6 +567,7 @@ gst_rtp_h265_set_src_caps (GstRtpH265Depay * rtph265depay)
 
       gst_caps_unref (tmp_caps);
     }
+    gst_caps_unref (old_caps);
   } else {
     res =
         gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph265depay),