mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 22:48:57 +02:00
* Fix integer overflow not being detected. Issue #39406
This commit is contained in:
parent
ee10850a57
commit
1e74c418ae
@ -960,10 +960,14 @@ begin
|
||||
end;
|
||||
|
||||
function TryStrToInt(const s: string; out i : Longint) : boolean;
|
||||
var Error : word;
|
||||
var
|
||||
Error : word;
|
||||
li : Int64;
|
||||
begin
|
||||
Val(s, i, Error);
|
||||
TryStrToInt:=Error=0
|
||||
Val(s, li, Error);
|
||||
TryStrToInt:=(Error=0) and (li<=High(Longint)) and (li>=Low(Longint));
|
||||
if TryStrToInt then
|
||||
i:=li;
|
||||
end;
|
||||
|
||||
{ StrToInt converts the string S to an integer value,
|
||||
|
Loading…
Reference in New Issue
Block a user