/* Empty pattern only matches the empty string. */
if (p == NULL || *p == '\0')
return (s == NULL || *s == '\0');
+ else if (s == NULL)
+ return (0);
/* Leading '^' anchors the start of the pattern. */
if (*p == '^') {
/* Empty pattern only matches the empty string. */
if (p == NULL || *p == L'\0')
return (s == NULL || *s == L'\0');
+ else if (s == NULL)
+ return (0);
/* Leading '^' anchors the start of the pattern. */
if (*p == L'^') {
assertEqualInt(0, archive_pathmatch("a/b/c", "a/b/", 0));
assertEqualInt(0, archive_pathmatch("a/b/c", "a/b", 0));
+ /* Null string and non-empty pattern returns false. */
+ assertEqualInt(0, archive_pathmatch("a/b/c", NULL, 0));
+ assertEqualInt(0, archive_pathmatch_w(L"a/b/c", NULL, 0));
+
/* Empty pattern only matches empty string. */
assertEqualInt(1, archive_pathmatch("","", 0));
assertEqualInt(0, archive_pathmatch("","a", 0));