From 88d7beb921ac15893fa886647ebccf8931cccdbb Mon Sep 17 00:00:00 2001 From: Dave Craig Date: Tue, 15 Dec 2015 17:10:00 +0000 Subject: [PATCH] videoparsers: Check for NULL return value of gst_pad_get_current_caps() https://bugzilla.gnome.org/show_bug.cgi?id=759503 --- gst/videoparsers/gstdiracparse.c | 13 +++++++++++-- gst/videoparsers/gsth263parse.c | 13 +++++++++++-- gst/videoparsers/gsth264parse.c | 4 ++-- gst/videoparsers/gsth265parse.c | 13 +++++++++++-- gst/videoparsers/gstmpeg4videoparse.c | 13 +++++++++++-- gst/videoparsers/gstmpegvideoparse.c | 12 +++++++++++- gst/videoparsers/gstpngparse.c | 13 +++++++++++-- gst/videoparsers/gstvc1parse.c | 13 +++++++++++-- 8 files changed, 79 insertions(+), 15 deletions(-) diff --git a/gst/videoparsers/gstdiracparse.c b/gst/videoparsers/gstdiracparse.c index c24b27c..93f00c6 100644 --- a/gst/videoparsers/gstdiracparse.c +++ b/gst/videoparsers/gstdiracparse.c @@ -396,10 +396,19 @@ gst_dirac_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) GstTagList *taglist; GstCaps *caps; - taglist = gst_tag_list_new_empty (); - /* codec tag */ caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (G_UNLIKELY (caps == NULL)) { + if (GST_PAD_IS_FLUSHING (GST_BASE_PARSE_SRC_PAD (parse))) { + GST_INFO_OBJECT (parse, "Src pad is flushing"); + return GST_FLOW_FLUSHING; + } else { + GST_INFO_OBJECT (parse, "Src pad is not negotiated!"); + return GST_FLOW_NOT_NEGOTIATED; + } + } + + taglist = gst_tag_list_new_empty (); gst_pb_utils_add_codec_description_to_tag_list (taglist, GST_TAG_VIDEO_CODEC, caps); gst_caps_unref (caps); diff --git a/gst/videoparsers/gsth263parse.c b/gst/videoparsers/gsth263parse.c index eb6290b..370cbb1 100644 --- a/gst/videoparsers/gsth263parse.c +++ b/gst/videoparsers/gsth263parse.c @@ -439,10 +439,19 @@ gst_h263_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) GstTagList *taglist; GstCaps *caps; - taglist = gst_tag_list_new_empty (); - /* codec tag */ caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (G_UNLIKELY (caps == NULL)) { + if (GST_PAD_IS_FLUSHING (GST_BASE_PARSE_SRC_PAD (parse))) { + GST_INFO_OBJECT (parse, "Src pad is flushing"); + return GST_FLOW_FLUSHING; + } else { + GST_INFO_OBJECT (parse, "Src pad is not negotiated!"); + return GST_FLOW_NOT_NEGOTIATED; + } + } + + taglist = gst_tag_list_new_empty (); gst_pb_utils_add_codec_description_to_tag_list (taglist, GST_TAG_VIDEO_CODEC, caps); gst_caps_unref (caps); diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 31d6a60..21df95e 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -2197,8 +2197,6 @@ gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) GstTagList *taglist; GstCaps *caps; - taglist = gst_tag_list_new_empty (); - /* codec tag */ caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); if (caps == NULL) { @@ -2210,6 +2208,8 @@ gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) return GST_FLOW_NOT_NEGOTIATED; } } + + taglist = gst_tag_list_new_empty (); gst_pb_utils_add_codec_description_to_tag_list (taglist, GST_TAG_VIDEO_CODEC, caps); gst_caps_unref (caps); diff --git a/gst/videoparsers/gsth265parse.c b/gst/videoparsers/gsth265parse.c index 8fb2080..67a16c6 100644 --- a/gst/videoparsers/gsth265parse.c +++ b/gst/videoparsers/gsth265parse.c @@ -1765,10 +1765,19 @@ gst_h265_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) GstTagList *taglist; GstCaps *caps; - taglist = gst_tag_list_new_empty (); - /* codec tag */ caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (G_UNLIKELY (caps == NULL)) { + if (GST_PAD_IS_FLUSHING (GST_BASE_PARSE_SRC_PAD (parse))) { + GST_INFO_OBJECT (parse, "Src pad is flushing"); + return GST_FLOW_FLUSHING; + } else { + GST_INFO_OBJECT (parse, "Src pad is not negotiated!"); + return GST_FLOW_NOT_NEGOTIATED; + } + } + + taglist = gst_tag_list_new_empty (); gst_pb_utils_add_codec_description_to_tag_list (taglist, GST_TAG_VIDEO_CODEC, caps); gst_caps_unref (caps); diff --git a/gst/videoparsers/gstmpeg4videoparse.c b/gst/videoparsers/gstmpeg4videoparse.c index 53db2d5..a1fd3b2 100644 --- a/gst/videoparsers/gstmpeg4videoparse.c +++ b/gst/videoparsers/gstmpeg4videoparse.c @@ -722,10 +722,19 @@ gst_mpeg4vparse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) GstTagList *taglist; GstCaps *caps; - taglist = gst_tag_list_new_empty (); - /* codec tag */ caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (G_UNLIKELY (caps == NULL)) { + if (GST_PAD_IS_FLUSHING (GST_BASE_PARSE_SRC_PAD (parse))) { + GST_INFO_OBJECT (parse, "Src pad is flushing"); + return GST_FLOW_FLUSHING; + } else { + GST_INFO_OBJECT (parse, "Src pad is not negotiated!"); + return GST_FLOW_NOT_NEGOTIATED; + } + } + + taglist = gst_tag_list_new_empty (); gst_pb_utils_add_codec_description_to_tag_list (taglist, GST_TAG_VIDEO_CODEC, caps); gst_caps_unref (caps); diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c index 54ee13b..5fa7165 100644 --- a/gst/videoparsers/gstmpegvideoparse.c +++ b/gst/videoparsers/gstmpegvideoparse.c @@ -948,8 +948,18 @@ gst_mpegv_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) GstCaps *caps; /* codec tag */ - taglist = gst_tag_list_new_empty (); caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (G_UNLIKELY (caps == NULL)) { + if (GST_PAD_IS_FLUSHING (GST_BASE_PARSE_SRC_PAD (parse))) { + GST_INFO_OBJECT (parse, "Src pad is flushing"); + return GST_FLOW_FLUSHING; + } else { + GST_INFO_OBJECT (parse, "Src pad is not negotiated!"); + return GST_FLOW_NOT_NEGOTIATED; + } + } + + taglist = gst_tag_list_new_empty (); gst_pb_utils_add_codec_description_to_tag_list (taglist, GST_TAG_VIDEO_CODEC, caps); gst_caps_unref (caps); diff --git a/gst/videoparsers/gstpngparse.c b/gst/videoparsers/gstpngparse.c index e08fe71..e9d0768 100644 --- a/gst/videoparsers/gstpngparse.c +++ b/gst/videoparsers/gstpngparse.c @@ -259,10 +259,19 @@ gst_png_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) GstTagList *taglist; GstCaps *caps; - taglist = gst_tag_list_new_empty (); - /* codec tag */ caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (G_UNLIKELY (caps == NULL)) { + if (GST_PAD_IS_FLUSHING (GST_BASE_PARSE_SRC_PAD (parse))) { + GST_INFO_OBJECT (parse, "Src pad is flushing"); + return GST_FLOW_FLUSHING; + } else { + GST_INFO_OBJECT (parse, "Src pad is not negotiated!"); + return GST_FLOW_NOT_NEGOTIATED; + } + } + + taglist = gst_tag_list_new_empty (); gst_pb_utils_add_codec_description_to_tag_list (taglist, GST_TAG_VIDEO_CODEC, caps); gst_caps_unref (caps); diff --git a/gst/videoparsers/gstvc1parse.c b/gst/videoparsers/gstvc1parse.c index d7d61f0..e72f4f6 100644 --- a/gst/videoparsers/gstvc1parse.c +++ b/gst/videoparsers/gstvc1parse.c @@ -1700,10 +1700,19 @@ gst_vc1_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) GstTagList *taglist; GstCaps *caps; - taglist = gst_tag_list_new_empty (); - /* codec tag */ caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (G_UNLIKELY (caps == NULL)) { + if (GST_PAD_IS_FLUSHING (GST_BASE_PARSE_SRC_PAD (parse))) { + GST_INFO_OBJECT (parse, "Src pad is flushing"); + return GST_FLOW_FLUSHING; + } else { + GST_INFO_OBJECT (parse, "Src pad is not negotiated!"); + return GST_FLOW_NOT_NEGOTIATED; + } + } + + taglist = gst_tag_list_new_empty (); gst_pb_utils_add_codec_description_to_tag_list (taglist, GST_TAG_VIDEO_CODEC, caps); gst_caps_unref (caps); -- 2.7.4