From 22cf2c8f4cfc5c41b30edeab26e17ec58abc0c43 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 28 Oct 2019 17:36:36 +0000 Subject: [PATCH] gtestutils: Add additional non-NULL check in g_assert_cmpmem() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The compiler can’t work out from the combination of other conditions that it’s not possible for (m2 == NULL) to hold true when memcmp() is called, so add an explicit condition. Signed-off-by: Philip Withnall Fixes: #1897 --- glib/gtestutils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gtestutils.h b/glib/gtestutils.h index c4203f010..66b7ef3b7 100644 --- a/glib/gtestutils.h +++ b/glib/gtestutils.h @@ -89,7 +89,7 @@ typedef void (*GTestFixtureFunc) (gpointer fixture, g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", \ (long double) __l1, "==", (long double) __l2, 'i'); \ - else if (__l1 != 0 && memcmp (__m1, __m2, __l1) != 0) \ + else if (__l1 != 0 && __m2 != NULL && memcmp (__m1, __m2, __l1) != 0) \ g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ "assertion failed (" #m1 " == " #m2 ")"); \ } G_STMT_END