From 99d3c9425d27ae95c95a734eb0017b91f1590d7a Mon Sep 17 00:00:00 2001 From: Paul Harris Date: Tue, 23 Jun 2015 22:20:17 +0800 Subject: [PATCH] Test 330 - Add assert to catch a segfault. The assert shouldn't fail, but it currently does. --- .../test/test_read_format_zip_utf8_paths.c | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libarchive/test/test_read_format_zip_utf8_paths.c b/libarchive/test/test_read_format_zip_utf8_paths.c index 65b711e99..86d587c96 100644 --- a/libarchive/test/test_read_format_zip_utf8_paths.c +++ b/libarchive/test/test_read_format_zip_utf8_paths.c @@ -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)); } -- 2.47.2