Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/GStreamer/gstreamer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2020-04-13 03:33:43 +0300
committerTim-Philipp Müller <tim@centricular.com>2020-06-07 03:41:52 +0300
commitc666a9a7e13cdccdfd937066889e8085c452f7ac (patch)
treed7be07bc8ec876eeefa9723b4da32dce419d7f9e
parent177d0fa1c27873518213af0c603ba9616094b586 (diff)
value: Fix segfault comparing empty GValueArrays
Adding a test
-rw-r--r--gst/gstvalue.c4
-rw-r--r--tests/check/gst/gstvalue.c9
2 files changed, 11 insertions, 2 deletions
diff --git a/gst/gstvalue.c b/gst/gstvalue.c
index 8835dce08d..27b22c003f 100644
--- a/gst/gstvalue.c
+++ b/gst/gstvalue.c
@@ -1065,11 +1065,11 @@ gst_value_compare_g_value_array (const GValue * value1, const GValue * value2)
guint i;
GValueArray *array1 = value1->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 *v2;
- if (len != array2->n_values)
+ if (len != (array2 ? array2->n_values : 0))
return GST_VALUE_UNORDERED;
for (i = 0; i < len; i++) {
diff --git a/tests/check/gst/gstvalue.c b/tests/check/gst/gstvalue.c
index 841a4c8132..456862163c 100644
--- a/tests/check/gst/gstvalue.c
+++ b/tests/check/gst/gstvalue.c
@@ -1020,6 +1020,15 @@ GST_START_TEST (test_value_compare)
g_value_unset (&value2);
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);
gst_value_set_bitmask (&value1, 0x123);
g_value_init (&value2, GST_TYPE_BITMASK);