Consider converting GValue with nullptr GValueArray to an empty string
Describe your issue
If you call get_defs
from Glibmm's libglibmm_generate_extra_defs-2.68.so
on GstAudioInterleave
, get_defs
raises a segmentation fault.
Expected Behavior
No segmentation fault.
Observed Behavior
Segmentation fault.
Here is what is going on. The segmentation fault happens when Glibmm tries to extract the default value for the channel-positions
property of GstAudioInterleave
. It calls g_param_spec_get_default_value
to extract the default value from the channel-positions
property specification. Then it passes this default value to g_value_transform
with the second argument of type G_TYPE_STRING
. Everything looks legitimate at this point. Yet, the code explodes on a null pointer dereference. It happens because g_value_transform
ends up in the GStreamer code here:
static void
_gst_value_transform_g_value_array_string (const GValue * src_value,
GValue * dest_value, const gchar * begin, const gchar * end)
{
GValue *list_value;
GValueArray *array;
GString *s;
guint i;
gchar *list_s;
guint alen;
array = src_value->data[0].v_pointer;
alen = array->n_values;
The last line above dereferences a null pointer. It happens because channel-positions
has an array type. A default value for it is set by a call to boxed_proxy_value_init
, which initializes data[0].v_pointer
with NULL.
Since a null pointer is a valid initial value for an array, I believe the right thing to do is to check if the array is NULL inside _gst_value_transform_g_value_array_string
and return an empty string.