value: Fix segfault comparing empty GValueArrays

Adding a test
This commit is contained in:
Thibault Saunier 2020-04-12 20:33:43 -04:00
parent 0566b0528a
commit 88f0312624
2 changed files with 11 additions and 2 deletions

View file

@ -1206,11 +1206,11 @@ gst_value_compare_g_value_array (const GValue * value1, const GValue * value2)
guint i; guint i;
GValueArray *array1 = value1->data[0].v_pointer; GValueArray *array1 = value1->data[0].v_pointer;
GValueArray *array2 = value2->data[0].v_pointer; GValueArray *array2 = value2->data[0].v_pointer;
guint len = array1->n_values; guint len = array1 ? array1->n_values : 0;
GValue *v1; GValue *v1;
GValue *v2; GValue *v2;
if (len != array2->n_values) if (len != (array2 ? array2->n_values : 0))
return GST_VALUE_UNORDERED; return GST_VALUE_UNORDERED;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {

View file

@ -1020,6 +1020,15 @@ GST_START_TEST (test_value_compare)
g_value_unset (&value2); g_value_unset (&value2);
g_value_unset (&tmp); g_value_unset (&tmp);
g_value_init (&value1, G_TYPE_VALUE_ARRAY);
g_value_init (&value2, G_TYPE_VALUE_ARRAY);
fail_unless (gst_value_compare (&value1, &value2) == GST_VALUE_EQUAL,
"Empty Value arrays aren't equals when they should");
g_value_unset (&value1);
g_value_unset (&value2);
g_value_init (&value1, GST_TYPE_BITMASK); g_value_init (&value1, GST_TYPE_BITMASK);
gst_value_set_bitmask (&value1, 0x123); gst_value_set_bitmask (&value1, 0x123);
g_value_init (&value2, GST_TYPE_BITMASK); g_value_init (&value2, GST_TYPE_BITMASK);