talloc torture: avoid NULL dereference
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 1 May 2019 23:29:34 +0000 (11:29 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 9 May 2019 22:39:26 +0000 (22:39 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
lib/talloc/testsuite.c

index 35309e2af253a035e2653c74a6e50c838dddb686..a76a64716c8f5378c96c606d12c4e9deb691d94a 100644 (file)
@@ -63,7 +63,9 @@ static double private_timeval_elapsed(struct timeval *tv)
 }
 
 #define torture_assert_str_equal(test, arg1, arg2, desc) \
-       if (arg1 == NULL && arg2 == NULL) {                             \
+       if (arg1 == NULL && arg2 == NULL) { /* OK, both NULL == equal */ \
+       } else if (arg1 == NULL || arg2 == NULL) {                      \
+               return false;                                           \
        } else if (strcmp(arg1, arg2)) {                        \
                printf("failure: %s [\n%s: Expected %s, got %s: %s\n]\n", \
                   test, __location__, arg1, arg2, desc); \