mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 23:16:14 +01:00
gbytes: Avoid memcmp (NULL, ., 0) or memcmp (., NULL, 0)
Similar to 3837b83f
, glibc memcmp is declared with the first two
arguments annotated as non-null via an attribute, which results in the
undefined behaviour sanitizer considering it to be UB to pass a null
pointer there (even if we are comparing 0 bytes, and hence not actually
dereferencing the pointer).
This shows up in /gvariant/serialiser/children when run with the
undefined behaviour sanitizer.
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
2465e64c93
commit
8235bbe467
@ -365,7 +365,7 @@ g_bytes_equal (gconstpointer bytes1,
|
|||||||
g_return_val_if_fail (bytes2 != NULL, FALSE);
|
g_return_val_if_fail (bytes2 != NULL, FALSE);
|
||||||
|
|
||||||
return b1->size == b2->size &&
|
return b1->size == b2->size &&
|
||||||
memcmp (b1->data, b2->data, b1->size) == 0;
|
(b1->size == 0 || memcmp (b1->data, b2->data, b1->size) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user