From b5c4e6d99ac0dc5e9aa20cabdb7208b11e7b6966 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 17 Nov 2016 13:48:58 -0500 Subject: [PATCH] [UBSAN] deltas: Don't call memset(NULL, NULL, 0) with no xattrs This is actually fine in practice, but it triggers this `-fsanitize=undefined` warning I saw in the test suite log: ``` src/libostree/ostree-repo-static-delta-compilation.c:160:10: runtime error: null pointer passed as argument 1, which is declared to never be null ``` Closes: #584 Approved by: jlebon --- src/libostree/ostree-repo-static-delta-compilation.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c index 286c74e1..4b0bc507 100644 --- a/src/libostree/ostree-repo-static-delta-compilation.c +++ b/src/libostree/ostree-repo-static-delta-compilation.c @@ -157,6 +157,9 @@ xattr_chunk_equals (const void *one, const void *two) if (l1 != l2) return FALSE; + if (l1 == 0) + return l2 == 0; + return memcmp (g_variant_get_data (v1), g_variant_get_data (v2), l1) == 0; }