builtin-for-each-ref.c::copy_name() - do not overstep the buffer.
[gitweb.git] / builtin-for-each-ref.c
index 725c1df0fca375e9585ac09757f68204406598ec..e868a4b6d7f2fe59437ccab12ea7a9b16f4a2163 100644 (file)
@@ -309,7 +309,7 @@ static const char *copy_line(const char *buf)
 static const char *copy_name(const char *buf)
 {
        const char *cp;
-       for (cp = buf; *cp != '\n'; cp++) {
+       for (cp = buf; *cp && *cp != '\n'; cp++) {
                if (!strncmp(cp, " <", 2))
                        return xmemdupz(buf, cp - buf);
        }