]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Avoid core dump.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 14 Oct 2009 10:10:00 +0000 (06:10 -0400)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 14 Oct 2009 10:10:00 +0000 (06:10 -0400)
SVN-Revision: 1518

libarchive/test/main.c

index 18693d4ef2c811797136fc1834f550ac1dbe727e..4bcec392d0aafb5e33076717cb86504bade138fb 100644 (file)
@@ -406,7 +406,7 @@ static void strdump(const char *e, const char *p)
 {
        logprintf("      %s = ", e);
        if (p == NULL) {
-               logprintf("(null)");
+               logprintf("(null)\n");
                return;
        }
        logprintf("\"");
@@ -436,7 +436,7 @@ assertion_equal_string(const char *file, int line,
     void *extra)
 {
        assertion_count(file, line);
-       if (v1 == v2 || strcmp(v1, v2) == 0)
+       if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
                return (1);
        failure_start(file, line, "%s != %s", e1, e2);
        strdump(e1, v1);
@@ -496,6 +496,10 @@ hexdump(const char *p, const char *ref, size_t l, size_t offset)
        size_t i, j;
        char sep;
 
+       if (p == NULL) {
+               logprintf("(null)\n");
+               return;
+       }
        for(i=0; i < l; i+=16) {
                logprintf("%04x", (unsigned)(i + offset));
                sep = ' ';
@@ -535,7 +539,7 @@ assertion_equal_mem(const char *file, int line,
        size_t offset;
 
        assertion_count(file, line);
-       if (v1 == v2 || memcmp(v1, v2, l) == 0)
+       if (v1 == v2 || (v1 != NULL && v2 != NULL && memcmp(v1, v2, l) == 0))
                return (1);
 
        failure_start(file, line, "%s != %s", e1, e2);