@matheusbsbs / matheus-bagliano / commits / 17cf250aff
Fork 0

Off-by-one error in get_path_prefix(), found by Valgrind

[jc: original fix was done by Pavel and this contains improvements by Rene.] Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Acked-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Rene Scharfe committed Jun 7, 2006 at 20:05 UTC 17cf250aff26d3baa6b311a3404f1a932e16cf17
1 file changed +2 -1
builtin-tar-tree.c
+2 -1
@@ -168,8 +168,9 @@ static int get_path_prefix(const struct strbuf *path, int maxlen)
168 int i = path->len;
169 if (i > maxlen)
170 i = maxlen;
171 - while (i > 0 && path->buf[i] != '/')
171 + do {
172 i--;
173 + } while (i > 0 && path->buf[i] != '/');
174 return i;
175 }
176