cache_tree_find(): find the end of path component using strchrnul()
authorMichael Haggerty <mhagger@alum.mit.edu>
Wed, 5 Mar 2014 17:26:26 +0000 (18:26 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Mar 2014 20:33:30 +0000 (12:33 -0800)
Suggested-by: Junio Hamano <gitster@pobox.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache-tree.c
index 4d439bd915a38f029ff8d54b76f6730231705090..d00f4ef7c2cb44392007e1f41cc2d0bc4d1e5c76 100644 (file)
@@ -554,9 +554,7 @@ static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *pat
                const char *slash;
                struct cache_tree_sub *sub;
 
-               slash = strchr(path, '/');
-               if (!slash)
-                       slash = path + strlen(path);
+               slash = strchrnul(path, '/');
                /* between path and slash is the name of the
                 * subtree to look for.
                 */