taglist: Fix crash when comparing two lists of the same length but with different items

Fixes #549

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/469>
This commit is contained in:
Matej Knopp 2020-05-07 23:00:13 +02:00 committed by Sebastian Dröge
parent e329e1f769
commit cab5b22f21
2 changed files with 20 additions and 1 deletions

View file

@ -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;

View file

@ -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);