builtin-for-each-ref.c::copy_name() - do not overstep the buffer.

This was introduced during xmemdupz() conversion.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2007-09-19 01:52:59 -07:00
parent ca0328354a
commit 6b30852ded

View File

@ -309,7 +309,7 @@ static const char *copy_line(const char *buf)
static const char *copy_name(const char *buf) static const char *copy_name(const char *buf)
{ {
const char *cp; const char *cp;
for (cp = buf; *cp != '\n'; cp++) { for (cp = buf; *cp && *cp != '\n'; cp++) {
if (!strncmp(cp, " <", 2)) if (!strncmp(cp, " <", 2))
return xmemdupz(buf, cp - buf); return xmemdupz(buf, cp - buf);
} }