From: Rene Scharfe Date: Wed, 7 Jun 2006 18:05:43 +0000 (+0200) Subject: Off-by-one error in get_path_prefix(), found by Valgrind X-Git-Tag: v1.4.0-rc2~11 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=17cf250aff26d3baa6b311a3404f1a932e16cf17;p=git.git 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 --- diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c index 5f740cf70..7663b9bd8 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; }