[glib/glib-2-62: 3/8] gtestutils: Add additional non-NULL check in	g_assert_cmpmem()
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [glib/glib-2-62: 3/8] gtestutils: Add additional non-NULL check in	g_assert_cmpmem()
- Date: Tue, 29 Oct 2019 14:21:40 +0000 (UTC)
commit 531baac79d51b64fadd25a54ac2bb8a591765dd2
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Oct 28 17:36:36 2019 +0000
    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
 glib/gtestutils.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 26de21216..6c475e5f4 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -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
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]