]> git.ipfire.org Git - thirdparty/git.git/blobdiff - path.c
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / path.c
diff --git a/path.c b/path.c
index 81e9bfe7a93eb3ede1ba8b142a31bab9213f2f91..4b69360c71f1839c217ecc62a9d6dea24924db0e 100644 (file)
--- a/path.c
+++ b/path.c
@@ -299,9 +299,13 @@ static int trie_find(struct trie *root, const char *key, match_fn fn,
 
        /* Matched the entire compressed section */
        key += i;
-       if (!*key)
+       if (!*key) {
                /* End of key */
-               return fn(key, root->value, baton);
+               if (root->value)
+                       return fn(key, root->value, baton);
+               else
+                       return -1;
+       }
 
        /* Partial path normalization: skip consecutive slashes */
        while (key[0] == '/' && key[1] == '/')
@@ -345,9 +349,6 @@ static int check_common(const char *unmatched, void *value, void *baton)
 {
        struct common_dir *dir = value;
 
-       if (!dir)
-               return 0;
-
        if (dir->is_dir && (unmatched[0] == 0 || unmatched[0] == '/'))
                return dir->is_common;