From: Matej Knopp Date: Thu, 7 May 2020 21:00:13 +0000 (+0200) Subject: taglist: Fix crash when comparing two lists of the same length but with different... X-Git-Tag: 1.19.3~884 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cab5b22f217b618f4d4e52fe0c8c030248e5b7dd;p=platform%2Fupstream%2Fgstreamer.git taglist: Fix crash when comparing two lists of the same length but with different items Fixes #549 Part-of: --- diff --git a/gst/gsttaglist.c b/gst/gsttaglist.c index 0375c81..965630f 100644 --- a/gst/gsttaglist.c +++ b/gst/gsttaglist.c @@ -959,9 +959,13 @@ gst_tag_list_fields_equal (GQuark field_id, const GValue * value2, { const GstStructure *struct1 = (const GstStructure *) data; const GValue *value1 = gst_structure_id_get_value (struct1, field_id); - gdouble d1, d2; + if (value1 == NULL) { + /* no value with this field id, clearly not equal */ + return FALSE; + } + if (gst_value_compare (value1, value2) == GST_VALUE_EQUAL) return TRUE; diff --git a/tests/check/gst/gsttag.c b/tests/check/gst/gsttag.c index d330cb3..99a87cd 100644 --- a/tests/check/gst/gsttag.c +++ b/tests/check/gst/gsttag.c @@ -500,6 +500,21 @@ GST_START_TEST (test_equal) gst_tag_list_unref (tags); gst_tag_list_unref (tags2); + /* test comparing lists with equal length but different items */ + + tags = gst_tag_list_new_empty (); + gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_ARTIST, "Foo", NULL); + gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_ARTIST, "Bar", NULL); + + tags2 = gst_tag_list_new_empty (); + gst_tag_list_add (tags2, GST_TAG_MERGE_APPEND, GST_TAG_TITLE, "Foo", NULL); + gst_tag_list_add (tags2, GST_TAG_MERGE_APPEND, GST_TAG_TITLE, "Bar", NULL); + + fail_unless (!gst_tag_list_is_equal (tags2, tags)); + + gst_tag_list_unref (tags); + gst_tag_list_unref (tags2); + /* samples */ buf = gst_buffer_new_wrapped (g_strdup ("test 1-2-3"), 10); sample1 = gst_sample_new (buf, NULL, NULL, NULL);