From 49f46319097fd723909a6eeb749ead9fbd497806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 23 Feb 2016 18:27:47 +0200 Subject: gst: Handle gst_pad_get_current_caps() returning NULL gracefully --- ext/dv/gstdvdec.c | 3 +++ ext/gdk_pixbuf/gstgdkpixbufdec.c | 2 ++ gst/deinterlace/gstdeinterlace.c | 5 +++-- gst/smpte/gstsmpte.c | 6 ++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c index 4fd01c9a2..89911d70c 100644 --- a/ext/dv/gstdvdec.c +++ b/ext/dv/gstdvdec.c @@ -479,6 +479,9 @@ gst_dvdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) GstCaps *caps; caps = gst_pad_get_current_caps (dvdec->srcpad); + if (!caps) + goto not_negotiated; + gst_dvdec_negotiate_pool (dvdec, caps, &dvdec->vinfo); gst_caps_unref (caps); } diff --git a/ext/gdk_pixbuf/gstgdkpixbufdec.c b/ext/gdk_pixbuf/gstgdkpixbufdec.c index 36cfbc027..589e74fa3 100644 --- a/ext/gdk_pixbuf/gstgdkpixbufdec.c +++ b/ext/gdk_pixbuf/gstgdkpixbufdec.c @@ -228,6 +228,8 @@ gst_gdk_pixbuf_dec_setup_pool (GstGdkPixbufDec * filter, GstVideoInfo * info) guint size, min, max; target = gst_pad_get_current_caps (filter->srcpad); + if (!target) + return FALSE; /* try to get a bufferpool now */ /* find a pool for the negotiated caps now */ diff --git a/gst/deinterlace/gstdeinterlace.c b/gst/deinterlace/gstdeinterlace.c index 6d2e68c11..8bf824780 100644 --- a/gst/deinterlace/gstdeinterlace.c +++ b/gst/deinterlace/gstdeinterlace.c @@ -1546,8 +1546,9 @@ restart: /* setcaps on sink and src pads */ sinkcaps = gst_pad_get_current_caps (self->sinkpad); - if (!gst_deinterlace_setcaps (self, self->sinkpad, sinkcaps)) { - gst_caps_unref (sinkcaps); + if (!sinkcaps || !gst_deinterlace_setcaps (self, self->sinkpad, sinkcaps)) { + if (sinkcaps) + gst_caps_unref (sinkcaps); return GST_FLOW_NOT_NEGOTIATED; } diff --git a/gst/smpte/gstsmpte.c b/gst/smpte/gstsmpte.c index 294d809ea..33d428427 100644 --- a/gst/smpte/gstsmpte.c +++ b/gst/smpte/gstsmpte.c @@ -559,8 +559,10 @@ input_formats_do_not_match: GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL), ("input formats don't match: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT, caps1, caps2)); - gst_caps_unref (caps1); - gst_caps_unref (caps2); + if (caps1) + gst_caps_unref (caps1); + if (caps2) + gst_caps_unref (caps2); return GST_FLOW_ERROR; } } -- cgit v1.2.1