Merge pull request #19 from cryb-to/cryb-test

Fix double-NULL case.
This commit is contained in:
Dag-Erling Smørgrav 2019-02-22 14:36:03 +02:00 committed by GitHub
commit ca82fe9e4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,7 +110,8 @@ t_compare_mem(const void *expected, const void *received, size_t len)
t_printv("\n");
t_printv("received null pointer\n");
return (0);
} else if (memcmp(expected, received, len) != 0) {
} else if (expected != NULL && received != NULL &&
memcmp(expected, received, len) != 0) {
t_printv("expected ");
t_printv_hex(expected, len);
t_printv("\n");
@ -137,7 +138,8 @@ t_compare_str(const char *expected, const char *received)
t_printv("expected \"%s\"\n", expected);
t_printv("received null pointer\n");
return (0);
} else if (strcmp(expected, received) != 0) {
} else if (expected != NULL && received != NULL &&
strcmp(expected, received) != 0) {
t_printv("expected %s\n", expected);
t_printv("received %s\n", received);
return (0);