summaryrefslogtreecommitdiff
path: root/builtin-tar-tree.c
diff options
context:
space:
mode:
authorRene Scharfe <rene.scharfe@lsrfire.ath.cx>2006-06-07 18:05:43 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-06-07 18:49:08 (GMT)
commit17cf250aff26d3baa6b311a3404f1a932e16cf17 (patch)
treeb69bfe7cb653bb48e36f96bb21f92a382e04aec0 /builtin-tar-tree.c
parent7fb23e6083dbefa8eb4c554d8b2cd5a6292b2df4 (diff)
downloadgit-17cf250aff26d3baa6b311a3404f1a932e16cf17.zip
git-17cf250aff26d3baa6b311a3404f1a932e16cf17.tar.gz
git-17cf250aff26d3baa6b311a3404f1a932e16cf17.tar.bz2
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>
Diffstat (limited to 'builtin-tar-tree.c')
-rw-r--r--builtin-tar-tree.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index 5f740cf..7663b9b 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;
}