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
This commit is contained in:
Philip Withnall 2019-10-28 17:36:36 +00:00
parent 9dc2fca288
commit 531baac79d

View File

@ -83,7 +83,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