1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Fix overflow check in tm2timestamp (this time for sure).

I fixed this code back in commit 841b4a2d5, but didn't think carefully
enough about the behavior near zero, which meant it improperly rejected
1999-12-31 24:00:00.  Per report from Magnus Hagander.
This commit is contained in:
Tom Lane
2013-03-04 15:13:31 -05:00
parent d4f4bdf23a
commit fa852303f0
2 changed files with 6 additions and 4 deletions

View File

@ -1646,8 +1646,9 @@ tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
return -1;
}
/* check for just-barely overflow (okay except time-of-day wraps) */
if ((*result < 0 && date >= 0) ||
(*result >= 0 && date < 0))
/* caution: we want to allow 1999-12-31 24:00:00 */
if ((*result < 0 && date > 0) ||
(*result > 0 && date < -1))
{
*result = 0; /* keep compiler quiet */
return -1;