[glib: 1/2] gtestutils: Add additional non-NULL check in g_assert_cmpmem()



commit 22cf2c8f4cfc5c41b30edeab26e17ec58abc0c43
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 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]