X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=refs.c;h=07e260c8a15c9118ee829964aed65b209900dc36;hb=6e863d6d129a1b6a13c66d0bb03f3d43db6c51fe;hp=7fb3350789a407e36dc74418b79508e9bf916594;hpb=07efafef2bcd87b35bf8880364dd5d098058cd4e;p=git.git diff --git a/refs.c b/refs.c index 7fb335078..07e260c8a 100644 --- a/refs.c +++ b/refs.c @@ -1246,15 +1246,11 @@ int create_symref(const char *ref_target, const char *refs_heads_master, static char *ref_msg(const char *line, const char *endp) { const char *ep; - char *msg; - line += 82; - for (ep = line; ep < endp && *ep != '\n'; ep++) - ; - msg = xmalloc(ep - line + 1); - memcpy(msg, line, ep - line); - msg[ep - line] = 0; - return msg; + ep = memchr(line, '\n', endp - line); + if (!ep) + ep = endp; + return xmemdupz(line, ep - line); } int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)