Merge branch 'wip/smcv/memcmp-null' into 'master'

gvariant, gbytes: Avoid memcmp (NULL, ., 0) or memcmp (., NULL, 0)

See merge request GNOME/glib!1214
This commit is contained in:
Philip Withnall 2019-11-04 16:51:01 +00:00
commit 3b980ab9eb
2 changed files with 5 additions and 2 deletions

View File

@ -365,7 +365,7 @@ g_bytes_equal (gconstpointer bytes1,
g_return_val_if_fail (bytes2 != NULL, FALSE);
return b1->size == b2->size &&
memcmp (b1->data, b2->data, b1->size) == 0;
(b1->size == 0 || memcmp (b1->data, b2->data, b1->size) == 0);
}
/**

View File

@ -2765,7 +2765,10 @@ g_variant_equal (gconstpointer one,
data_one = g_variant_get_data ((GVariant *) one);
data_two = g_variant_get_data ((GVariant *) two);
equal = memcmp (data_one, data_two, size_one) == 0;
if (size_one)
equal = memcmp (data_one, data_two, size_one) == 0;
else
equal = TRUE;
}
else
{