nvcodec: fix caps leaks in nvh264/h265encoder
authorCorentin Damman <c.damman@intopix.com>
Tue, 9 Aug 2022 10:24:53 +0000 (12:24 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 10 Aug 2022 12:24:37 +0000 (12:24 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2850>

subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.cpp
subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.cpp

index 3381547..21dc5ba 100644 (file)
@@ -1877,6 +1877,7 @@ gst_nv_h264_encoder_create_class_data (GstObject * device, gpointer session,
   if (device_mode == GST_NV_ENCODER_DEVICE_CUDA)
     g_object_get (device, "cuda-device-id", &cdata->cuda_device_id, nullptr);
 
+  /* class data will be leaked if the element never gets instantiated */
   GST_MINI_OBJECT_FLAG_SET (cdata->sink_caps,
       GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
   GST_MINI_OBJECT_FLAG_SET (cdata->src_caps,
@@ -2185,6 +2186,12 @@ gst_nv_h264_encoder_register_auto_select (GstPlugin * plugin,
   memcpy (&cdata->cuda_device_id_list,
       cuda_device_id_list, sizeof (cuda_device_id_list));
 
+  /* class data will be leaked if the element never gets instantiated */
+  GST_MINI_OBJECT_FLAG_SET (cdata->sink_caps,
+      GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
+  GST_MINI_OBJECT_FLAG_SET (cdata->src_caps,
+      GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
+
   GType type;
   GTypeInfo type_info = {
     sizeof (GstNvH264EncoderClass),
index 6361300..3d6b779 100644 (file)
@@ -1888,6 +1888,7 @@ gst_nv_h265_encoder_create_class_data (GstObject * device, gpointer session,
   if (device_mode == GST_NV_ENCODER_DEVICE_CUDA)
     g_object_get (device, "cuda-device-id", &cdata->cuda_device_id, nullptr);
 
+  /* class data will be leaked if the element never gets instantiated */
   GST_MINI_OBJECT_FLAG_SET (cdata->sink_caps,
       GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
   GST_MINI_OBJECT_FLAG_SET (cdata->src_caps,
@@ -2191,6 +2192,12 @@ gst_nv_h265_encoder_register_auto_select (GstPlugin * plugin,
   memcpy (&cdata->cuda_device_id_list,
       cuda_device_id_list, sizeof (cuda_device_id_list));
 
+  /* class data will be leaked if the element never gets instantiated */
+  GST_MINI_OBJECT_FLAG_SET (cdata->sink_caps,
+      GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
+  GST_MINI_OBJECT_FLAG_SET (cdata->src_caps,
+      GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
+
   GType type;
   GTypeInfo type_info = {
     sizeof (GstNvH265EncoderClass),