mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
element: Add sanity check with a critical warning if a pad is requested for a pad template that is not installed on the element class
Various elements are assuming that the pointer matches a pad template they know about, and also randomly created pad templates might be missing some important information that is necessary to create a valid pad. For example, creating a new pad template for audiomixer's sinkpad without providing the correct GType would cause audiomixer to create a GstAggregatorPad. That will then later fail spectacularly because it assumes that it got a GstAudioAggregatorPad. Passing a pad template that does not belong to the element class in here will easily lead to undefined behaviour. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2410>
This commit is contained in:
parent
aa3b6a11e0
commit
fbf0cc2279
1 changed files with 10 additions and 0 deletions
|
@ -1165,6 +1165,16 @@ _gst_element_request_pad (GstElement * element, GstPadTemplate * templ,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GST_ENABLE_EXTRA_CHECKS
|
||||||
|
{
|
||||||
|
if (!g_list_find (oclass->padtemplates, templ)) {
|
||||||
|
/* FIXME 2.0: Change this to g_return_val_if_fail() */
|
||||||
|
g_critical ("Element type %s does not have a pad template %s (%p)",
|
||||||
|
g_type_name (G_OBJECT_TYPE (element)), templ->name_template, templ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (oclass->request_new_pad)
|
if (oclass->request_new_pad)
|
||||||
newpad = (oclass->request_new_pad) (element, templ, name, caps);
|
newpad = (oclass->request_new_pad) (element, templ, name, caps);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue