]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Test 330 - Add assert to catch a segfault. 566/head
authorPaul Harris <paulharris@computer.org>
Tue, 23 Jun 2015 14:20:17 +0000 (22:20 +0800)
committerPaul Harris <paulharris@computer.org>
Tue, 23 Jun 2015 14:34:40 +0000 (22:34 +0800)
The assert shouldn't fail, but it currently does.

libarchive/test/test_read_format_zip_utf8_paths.c

index 65b711e9950b7f942fb6f4355aea1f2cdce4cd54..86d587c965c0b1b50e7be37ce97c8d7106a3be3b 100644 (file)
@@ -44,19 +44,21 @@ verify(struct archive *a) {
 
        for (file = 0; file < 20; ++file) {
                assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
-               wp = archive_entry_pathname_w(ae);
-               for (i = 0; wp[i] != 0; ++i) {
-                       if (wp[i] == '2') {
-                               failure("Unicode 'o with umlaut' expected");
-                               assertEqualInt(wp[i + 4], 0xF6);
-                       } else if (wp[i] == '3') {
-                               failure("Unicode 'a with umlaut' expected");
-                               assertEqualInt(wp[i + 4], 0xE4);
-                       } else if (wp[i] == '4') {
-                               failure("Unicode 'a with ring' expected");
-                               assertEqualInt(wp[i + 4], 0xE5);
-                       }
-               }
+               assert((wp = archive_entry_pathname_w(ae)) != NULL);
+      if (wp) {
+         for (i = 0; wp[i] != 0; ++i) {
+            if (wp[i] == '2') {
+               failure("Unicode 'o with umlaut' expected");
+               assertEqualInt(wp[i + 4], 0xF6);
+            } else if (wp[i] == '3') {
+               failure("Unicode 'a with umlaut' expected");
+               assertEqualInt(wp[i + 4], 0xE4);
+            } else if (wp[i] == '4') {
+               failure("Unicode 'a with ring' expected");
+               assertEqualInt(wp[i + 4], 0xE5);
+            }
+         }
+      }
        }
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 }