mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-12 18:49:46 +02:00
* proper range checking for TryStrToDWord, should resolve all issues in #39406
This commit is contained in:
parent
435f3a9fe2
commit
983fbff871
@ -1007,10 +1007,14 @@ begin
|
||||
end;
|
||||
|
||||
function TryStrToDWord(const s: string; Out D: DWord): boolean;
|
||||
var Error : word;
|
||||
var
|
||||
Error : word;
|
||||
lq : QWord;
|
||||
begin
|
||||
Val(s, D, Error);
|
||||
TryStrToDWord:=Error=0
|
||||
Val(s, lq, Error);
|
||||
TryStrToDWord:=(Error=0) and (lq<=High(DWord));
|
||||
if TryStrToDWord then
|
||||
D:=lq;
|
||||
end;
|
||||
|
||||
function StrToUInt(const s: string): Cardinal;
|
||||
|
14
tests/webtbs/tw39406.pp
Normal file
14
tests/webtbs/tw39406.pp
Normal file
@ -0,0 +1,14 @@
|
||||
{$mode objfpc}
|
||||
program fpbug;
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
var
|
||||
Value: Cardinal;
|
||||
Success: Boolean;
|
||||
begin
|
||||
Success := TryStrToDword('7795000000', Value);
|
||||
if Success then
|
||||
halt(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user