interlace: Fix crash with empty caps in setcaps
authorVivia Nikolaidou <vivia@ahiru.eu>
Thu, 11 Jun 2020 10:50:38 +0000 (13:50 +0300)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 11 Jun 2020 12:06:17 +0000 (12:06 +0000)
If the src_peer_caps are EMPTY (e.g. negotiation failed somewhere), the
assertion inside gst_video_info_from_caps would fail and the whole
pipeline would crash. Check for gst_caps_is_empty before
gst_video_info_from_caps and gracefully fail if it's empty.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1333>

gst/interlace/gstinterlace.c

index 635a99b..a15de74 100644 (file)
@@ -427,8 +427,14 @@ gst_interlace_setcaps (GstInterlace * interlace, GstCaps * caps)
   src_peer_caps = gst_pad_peer_query_caps (interlace->srcpad, othercaps);
   gst_caps_unref (othercaps);
   othercaps = gst_caps_fixate (src_peer_caps);
-  if (!gst_video_info_from_caps (&out_info, othercaps))
+  if (gst_caps_is_empty (othercaps)) {
+    gst_caps_unref (othercaps);
     goto caps_error;
+  }
+  if (!gst_video_info_from_caps (&out_info, othercaps)) {
+    gst_caps_unref (othercaps);
+    goto caps_error;
+  }
 
   alternate =
       GST_VIDEO_INFO_INTERLACE_MODE (&out_info) ==