mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-29 11:40:38 +00:00
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/887>
This commit is contained in:
parent
9289df4291
commit
fea7f02a1d
2 changed files with 12 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue