openh264enc: fix caps and header buffer leak
authorTim-Philipp Müller <tim@centricular.com>
Tue, 20 Apr 2021 18:43:53 +0000 (19:43 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Tue, 24 Aug 2021 22:42:27 +0000 (23:42 +0100)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2178>

ext/openh264/gstopenh264enc.cpp

index 1037941..502eca9 100644 (file)
@@ -811,6 +811,8 @@ gst_openh264enc_set_format (GstVideoEncoder * encoder,
   enc_params.sSpatialLayers[0].iSpatialBitrate = enc_params.iTargetBitrate;
   enc_params.sSpatialLayers[0].iMaxSpatialBitrate = enc_params.iMaxBitrate;
 
+  gst_clear_caps (&allowed_caps);
+
   if (openh264enc->slice_mode == GST_OPENH264_SLICE_MODE_N_SLICES) {
     if (openh264enc->num_slices == 1)
       slice_mode = SM_SINGLE_SLICE;
@@ -1050,7 +1052,7 @@ gst_openh264enc_handle_frame (GstVideoEncoder * encoder,
                 frame_info.sLayerInfo[i].pNalLengthInByte[j]);
           }
         }
-        headers = g_list_append (headers, gst_buffer_ref (hdr));
+        headers = g_list_append (headers, hdr);    /* take ownership of hdr */
     }
     gst_buffer_fill (frame->output_buffer, buf_length, frame_info.sLayerInfo[i].pBsBuf, layer_size);
     buf_length += layer_size;