Skip to content

Commit 7fcec48

Browse files
committed
parse_date_basic(): return early when given a bogus timestamp
When the input does not have GMT timezone offset, the code computes it by computing the local and GMT time for the given timestamp. But there is no point doing so if the given timestamp is known to be a bogus one. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 282616c commit 7fcec48

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

date.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,9 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
696696

697697
/* mktime uses local timezone */
698698
*timestamp = tm_to_time_t(&tm);
699+
if (*timestamp == -1)
700+
return -1;
701+
699702
if (*offset == -1) {
700703
time_t temp_time = mktime(&tm);
701704
if ((time_t)*timestamp > temp_time) {
@@ -705,9 +708,6 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
705708
}
706709
}
707710

708-
if (*timestamp == -1)
709-
return -1;
710-
711711
if (!tm_gmt)
712712
*timestamp -= *offset * 60;
713713
return 0; /* success */

0 commit comments

Comments
 (0)