summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2019-10-28 17:36:36 +0000
committerPhilip Withnall <withnall@endlessm.com>2019-10-28 17:36:36 +0000
commit22cf2c8f4cfc5c41b30edeab26e17ec58abc0c43 (patch)
tree20384fca155eb1aec497580effc4ce0092db02f8
parentc73bd53eb8748d204d496f63fd38ad7680a406b5 (diff)
downloadglib-22cf2c8f4cfc5c41b30edeab26e17ec58abc0c43.tar.gz
gtestutils: Add additional non-NULL check in g_assert_cmpmem()
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 <withnall@endlessm.com> Fixes: #1897
-rw-r--r--glib/gtestutils.h2
1 files changed, 1 insertions, 1 deletions
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