mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 13:08:49 +00:00
discoverer: Make sure the missing elements details array is NULL-terminated in a thread-safe way
And also avoid a possible out-of-bounds read if the array contains no elements. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7969>
This commit is contained in:
parent
fc30006290
commit
d553448b95
2 changed files with 9 additions and 7 deletions
|
@ -365,7 +365,12 @@ G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, G_TYPE_OBJECT);
|
|||
static void
|
||||
gst_discoverer_info_init (GstDiscovererInfo * info)
|
||||
{
|
||||
#if GLIB_CHECK_VERSION(2,74,0)
|
||||
info->missing_elements_details =
|
||||
g_ptr_array_new_null_terminated (16, g_free, TRUE);
|
||||
#else
|
||||
info->missing_elements_details = g_ptr_array_new_with_free_func (g_free);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1179,7 +1184,6 @@ const gchar **
|
|||
gst_discoverer_info_get_missing_elements_installer_details (const
|
||||
GstDiscovererInfo * info)
|
||||
{
|
||||
|
||||
if (info->result != GST_DISCOVERER_MISSING_PLUGINS) {
|
||||
GST_WARNING_OBJECT (info, "Trying to get missing element installed details "
|
||||
"but result is not 'MISSING_PLUGINS'");
|
||||
|
@ -1187,11 +1191,5 @@ gst_discoverer_info_get_missing_elements_installer_details (const
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (info->missing_elements_details->pdata[info->missing_elements_details->
|
||||
len]) {
|
||||
GST_DEBUG ("Adding NULL pointer to the end of missing_elements_details");
|
||||
g_ptr_array_add (info->missing_elements_details, NULL);
|
||||
}
|
||||
|
||||
return (const gchar **) info->missing_elements_details->pdata;
|
||||
}
|
||||
|
|
|
@ -1519,6 +1519,10 @@ discoverer_collect (GstDiscoverer * dc)
|
|||
}
|
||||
|
||||
_ensure_info_tags (dc);
|
||||
#if !GLIB_CHECK_VERSION(2,74,0)
|
||||
/* Make sure the missing element details are NULL-terminated */
|
||||
g_ptr_array_add (info->missing_elements_details, NULL);
|
||||
#endif
|
||||
serialize_info_if_required (dc, dc->priv->current_info);
|
||||
if (dc->priv->async)
|
||||
emit_discovered (dc);
|
||||
|
|
Loading…
Reference in a new issue