From 17cf250aff26d3baa6b311a3404f1a932e16cf17 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Wed, 7 Jun 2006 20:05:43 +0200 Subject: 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 Acked-by: Pavel Roskin Signed-off-by: Junio C Hamano --- builtin-tar-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'builtin-tar-tree.c') diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c index 5f740cf702..7663b9bd8e 100644 --- a/builtin-tar-tree.c +++ b/builtin-tar-tree.c @@ -168,8 +168,9 @@ static int get_path_prefix(const struct strbuf *path, int maxlen) int i = path->len; if (i > maxlen) i = maxlen; - while (i > 0 && path->buf[i] != '/') + do { i--; + } while (i > 0 && path->buf[i] != '/'); return i; } -- cgit v1.2.3