TryNum2Long/TryHex2Long/TryDec2Long return True for a number that does not...
Brought to you by:
twm
TryNum2Long in u_dzConvertUtils (both the string and the AnsiString overload), and with it TryHex2Long and TryDec2Long, multiply up the digits in a UInt32 without checking for overflow:
TryHex2Long('100000000'), 9 hex digits, or TryDec2Long('4294967296')) wraps around, and the function returns True with a wrong value.{$Q+} the same input raises EIntOverflow, so the Try function raises.Also, an empty string returns True with the value 0.
Expected: False in all three cases. (The callers in u_dzGuidUtils check the lengths first and are not affected.)
Fixed in revision #2470.
TryNum2Long, and with it TryHex2Long and TryDec2Long, now return False for an empty string and for a number that does not fit into UInt32, and Value is 0 then. The overflow is checked before multiplying, so they no longer raise EIntOverflow with
{$Q+}either. The AnsiString overload now calls the string one. New tests in ConvertUtils.