Browse Source

fixed trystrtoint checking bounds

mattias 4 years ago
parent
commit
dd8c294f2b
1 changed files with 5 additions and 1 deletions
  1. 5 1
      packages/rtl/sysutils.pas

+ 5 - 1
packages/rtl/sysutils.pas

@@ -4665,7 +4665,11 @@ Var
 begin
 begin
   Result:=TryStrToInt(S,NI);
   Result:=TryStrToInt(S,NI);
   if Result then
   if Result then
+    begin
     res:=NI;
     res:=NI;
+    if (NI<low(res)) or (NI>high(res)) then
+      Result:=false;
+    end;
 end;
 end;
 
 
 
 
@@ -4776,7 +4780,7 @@ Var
   N : NativeInt;
   N : NativeInt;
 begin
 begin
   Result:=TryStrToInt(S,N);
   Result:=TryStrToInt(S,N);
-  Result:=(N>=0) and (N<=4294967295);
+  Result:=(N>=0) and (N<=high(longword));
   If Result then 
   If Result then 
     C:=N;
     C:=N;
 end;
 end;