Code

Fix off-by-one in read_tree_recursive
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 20 Apr 2009 17:44:53 +0000 (19:44 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Apr 2009 20:44:14 +0000 (13:44 -0700)
Found by valgrind.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tree.c

diff --git a/tree.c b/tree.c
index 0d703a0c473e65c60d9e130b4e1fd50b79e9462b..5ab90af256a664366f3f92b467f52634c0df3f79 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -62,6 +62,7 @@ static int match_tree_entry(const char *base, int baselen, const char *path, uns
                                continue;
                        /* pathspecs match only at the directory boundaries */
                        if (!matchlen ||
+                           baselen == matchlen ||
                            base[matchlen] == '/' ||
                            match[matchlen - 1] == '/')
                                return 1;