aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test
diff options
context:
space:
mode:
authorFrank Hunleth <[email protected]>2018-01-03 18:10:12 -0500
committerFrank Hunleth <[email protected]>2018-01-03 20:39:07 -0500
commit434e4774a4f7e70437ee8a50c7b99ff3bda67282 (patch)
tree585117a4e067be213694b50ddbf6ef023e9c8c85 /erts/emulator/test
parent93042b54da6a576b187bfb7b2222fc8a5a4d4f12 (diff)
downloadotp-434e4774a4f7e70437ee8a50c7b99ff3bda67282.tar.gz
otp-434e4774a4f7e70437ee8a50c7b99ff3bda67282.tar.bz2
otp-434e4774a4f7e70437ee8a50c7b99ff3bda67282.zip
Fail if ':' is passed to binary_to_integer/2
Before: 1> binary_to_integer(<<":">>, 16). 3 After: 1> binary_to_integer(<<":">>, 16). ** exception error: bad argument in function binary_to_integer/2 called as binary_to_integer(<<":">>,16) Prior to this change, both list_to_integer/2 and binary_to_integer/2 would convert strings with values between ASCII '9' up to '0'+base for base > 10. For example, when converting in base 16, you could pass ':', ';', '<', '=', '>', and '?' without getting an exception. This was due to a missing check in c2int_is_invalid_char(). This change adds the missing check and a regression test for passing ':'. It also simplifies the code and tightens up an out-of-bounds check to make it off-by-one rather than off-by-two.
Diffstat (limited to 'erts/emulator/test')
-rw-r--r--erts/emulator/test/num_bif_SUITE.erl2
1 files changed, 1 insertions, 1 deletions
diff --git a/erts/emulator/test/num_bif_SUITE.erl b/erts/emulator/test/num_bif_SUITE.erl
index 1c76eb8019..ac1a667185 100644
--- a/erts/emulator/test/num_bif_SUITE.erl
+++ b/erts/emulator/test/num_bif_SUITE.erl
@@ -491,7 +491,7 @@ t_string_to_integer(Config) when is_list(Config) ->
list_to_binary(Value),Base)),
{'EXIT', {badarg, _}} =
(catch erlang:list_to_integer(Value,Base))
- end,[{" 1",1},{" 1",37},{"2",2},{"C",11},
+ end,[{" 1",1},{" 1",37},{"2",2},{"B",11},{"b",11},{":", 16},
{"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111z",16},
{"1z111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",16},
{"111z11111111",16}]),