x264enc: fix crash on NULL caps when negotiation happens without a downstream peer
authorTim-Philipp Müller <tim@centricular.com>
Fri, 29 Nov 2013 15:49:29 +0000 (15:49 +0000)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 13 Dec 2013 13:30:24 +0000 (14:30 +0100)
gst-launch-1.0 videotestsrc ! x264enc

ext/x264/gstx264enc.c

index 5fc5e1217305774fba80123a82268a6fe23e536e..8ec88b3d36a30c82277582c1d8f696b7ea81627b 100644 (file)
@@ -1552,6 +1552,10 @@ gst_x264_enc_set_profile_and_level (GstX264Enc * encoder, GstCaps * caps)
   profile = gst_structure_get_string (s, "profile");
 
   allowed_caps = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder));
+
+  if (allowed_caps == NULL)
+    goto no_peer;
+
   if (!gst_caps_can_intersect (allowed_caps, caps)) {
     allowed_caps = gst_caps_make_writable (allowed_caps);
     allowed_caps = gst_caps_truncate (allowed_caps);
@@ -1581,6 +1585,8 @@ gst_x264_enc_set_profile_and_level (GstX264Enc * encoder, GstCaps * caps)
   }
   gst_caps_unref (allowed_caps);
 
+no_peer:
+
   return TRUE;
 }