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>
This commit is contained in:
Rene Scharfe 2006-06-07 20:05:43 +02:00 коммит произвёл Junio C Hamano
Родитель 7fb23e6083
Коммит 17cf250aff
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -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;
}