From 5fef7a40d0213d9bd8a7386234e7792ecc340c85 Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 11 Jun 2021 05:33:16 +0000 Subject: [PATCH] * Empty string cannot be number --- packages/rtl/system.pas | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/rtl/system.pas b/packages/rtl/system.pas index 21420f0..2f70403 100644 --- a/packages/rtl/system.pas +++ b/packages/rtl/system.pas @@ -664,6 +664,11 @@ function valint(const S: String; MinVal, MaxVal: NativeInt; out Code: Integer): var x: double; begin + if S='' then + begin + code:=1; + exit; + end; x:=Number(S); if isNaN(x) then case copy(s,1,1) of @@ -694,6 +699,11 @@ procedure val(const S: String; out NI: NativeUInt; out Code: Integer); var x : double; begin + if S='' then + begin + code:=1; + exit; + end; x:=Number(S); if isNaN(x) or (X<>Int(X)) or (X<0) then Code:=1 @@ -738,6 +748,11 @@ procedure val(const S : String; out d : double; out Code : Integer); Var x: double; begin + if S='' then + begin + code:=1; + exit; + end; x:=Number(S); if isNaN(x) then Code:=1