From: Sebastian Dröge Date: Mon, 20 Sep 2021 10:12:12 +0000 (+0300) Subject: gst: Initialize optional event/message fields when parsing X-Git-Tag: 1.19.3~515 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fea7f02a1dc5a0a4efb1e324adf2368f0363f7da;p=platform%2Fupstream%2Fgstreamer.git gst: Initialize optional event/message fields when parsing These might not exist inside the structure and then we would potentially keep around uninitialized memory from the caller in the out parameter. Part-of: --- diff --git a/gst/gstevent.c b/gst/gstevent.c index 9ace25a..225ed3b 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -863,6 +863,10 @@ gst_event_parse_gap_flags (GstEvent * event, GstGapFlags * flags) g_return_if_fail (event != NULL); g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_GAP); + /* Initialize to 0 for GAP events that don't have the field set */ + if (flags) + *flags = 0; + gst_structure_id_get (GST_EVENT_STRUCTURE (event), GST_QUARK (GAP_FLAGS), GST_TYPE_GAP_FLAGS, flags, NULL); } @@ -1478,6 +1482,9 @@ gst_event_parse_seek_trickmode_interval (GstEvent * event, g_return_if_fail (interval != NULL); g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_SEEK); + if (interval) + *interval = GST_CLOCK_TIME_NONE; + gst_structure_id_get (GST_EVENT_STRUCTURE (event), GST_QUARK (TRICKMODE_INTERVAL), GST_TYPE_CLOCK_TIME, interval, NULL); } @@ -1814,10 +1821,10 @@ gst_event_parse_stream (GstEvent * event, GstStream ** stream) g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START); if (stream) { + *stream = NULL; gst_structure_id_get (GST_EVENT_STRUCTURE (event), GST_QUARK (STREAM), GST_TYPE_STREAM, stream, NULL); } - } /** @@ -1852,6 +1859,7 @@ gst_event_parse_stream_flags (GstEvent * event, GstStreamFlags * flags) g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START); if (flags) { + *flags = 0; gst_structure_id_get (GST_EVENT_STRUCTURE (event), GST_QUARK (FLAGS), GST_TYPE_STREAM_FLAGS, flags, NULL); } @@ -1902,6 +1910,7 @@ gst_event_parse_group_id (GstEvent * event, guint * group_id) FALSE); if (group_id) { + *group_id = 0; return gst_structure_id_get (GST_EVENT_STRUCTURE (event), GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id, NULL); } diff --git a/gst/gstmessage.c b/gst/gstmessage.c index f3f2007..45d4f4f 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -2472,6 +2472,8 @@ gst_message_parse_group_id (GstMessage * message, guint * group_id) if (!group_id) return TRUE; + *group_id = 0; + structure = GST_MESSAGE_STRUCTURE (message); v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));