mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 17:23:04 +01:00
Avoid integer overflow in date arithmetic - thanks to Claudio
This commit is contained in:
parent
2ef9d6ae41
commit
6e945e5be7
@ -1388,14 +1388,16 @@ static dsc* evlDateDiff(Jrd::thread_db* tdbb, SysFunction* function, Jrd::jrd_no
|
||||
break;
|
||||
|
||||
case blr_extract_second:
|
||||
result = oneDay * (timestamp2.value().timestamp_date - timestamp1.value().timestamp_date);
|
||||
result = (SINT64) oneDay *
|
||||
(timestamp2.value().timestamp_date - timestamp1.value().timestamp_date);
|
||||
result += ((SINT64) timestamp2.value().timestamp_time -
|
||||
(SINT64) timestamp1.value().timestamp_time) /
|
||||
ISC_TIME_SECONDS_PRECISION;
|
||||
break;
|
||||
|
||||
case blr_extract_millisecond:
|
||||
result = oneDay * (timestamp2.value().timestamp_date - timestamp1.value().timestamp_date) * 1000;
|
||||
result = (SINT64) oneDay *
|
||||
(timestamp2.value().timestamp_date - timestamp1.value().timestamp_date) * 1000;
|
||||
result += ((SINT64) timestamp2.value().timestamp_time -
|
||||
(SINT64) timestamp1.value().timestamp_time) /
|
||||
(ISC_TIME_SECONDS_PRECISION / 1000);
|
||||
|
Loading…
Reference in New Issue
Block a user