summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sha1_name.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 6c9c1c75ad..6298c37ae3 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -352,8 +352,11 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
}
if (0 <= nth)
at_time = 0;
- else
- at_time = approxidate(str + at + 2);
+ else {
+ char *tmp = xstrndup(str + at + 2, reflog_len);
+ at_time = approxidate(tmp);
+ free(tmp);
+ }
if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
&co_time, &co_tz, &co_cnt)) {
if (at_time)