(cherry picked from commit 983fbff8711a8c625e494a981891a90d47847e14)
@@ -1006,10 +1006,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;
function StrToUInt(const s: string): Cardinal;
@@ -0,0 +1,14 @@
+{$mode objfpc}
+program fpbug;
+
+uses
+ SysUtils;
+ Value: Cardinal;
+ Success: Boolean;
+begin
+ Success := TryStrToDword('7795000000', Value);
+ if Success then
+ halt(1);
+end.