diff --git a/glib/gbytes.c b/glib/gbytes.c index 7b72886e5..ec6923188 100644 --- a/glib/gbytes.c +++ b/glib/gbytes.c @@ -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); } /** diff --git a/glib/gvariant.c b/glib/gvariant.c index b61bf7278..d7ec8dc70 100644 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@ -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 {