diff options
author | Lukas Larsson <[email protected]> | 2018-01-17 16:15:33 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2018-01-17 16:15:33 +0100 |
commit | 919b6ddc24e409ec78380af14511ad50a88b4525 (patch) | |
tree | b88c5b958e41944f777d4f05d6eb8254a6f927ea /erts/emulator/beam | |
parent | b5f2a0703882d919e15a0ca2e24616aa97033a77 (diff) | |
parent | 434e4774a4f7e70437ee8a50c7b99ff3bda67282 (diff) | |
download | otp-919b6ddc24e409ec78380af14511ad50a88b4525.tar.gz otp-919b6ddc24e409ec78380af14511ad50a88b4525.tar.bz2 otp-919b6ddc24e409ec78380af14511ad50a88b4525.zip |
Merge branch 'fhunleth/binary_to_integer_chec/PR-1671/OTP-14879' into maint
* fhunleth/binary_to_integer_chec/PR-1671/OTP-14879:
Fail if ':' is passed to binary_to_integer/2
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/big.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/erts/emulator/beam/big.c b/erts/emulator/beam/big.c index 5eaf262cd8..c5cb268f09 100644 --- a/erts/emulator/beam/big.c +++ b/erts/emulator/beam/big.c @@ -2549,12 +2549,17 @@ int term_equals_2pow32(Eterm x) } } +static ERTS_INLINE int c2int_is_valid_char(byte ch, int base) { + if (base <= 10) + return (ch >= '0' && ch < ('0' + base)); + else + return (ch >= '0' && ch <= '9') + || (ch >= 'A' && ch < ('A' + base - 10)) + || (ch >= 'a' && ch < ('a' + base - 10)); +} + static ERTS_INLINE int c2int_is_invalid_char(byte ch, int base) { - return (ch < '0' - || (ch > ('0' + base - 1) - && !(base > 10 - && ((ch >= 'a' && ch < ('a' + base - 10)) - || (ch >= 'A' && ch < ('A' + base - 10)))))); + return !c2int_is_valid_char(ch, base); } static ERTS_INLINE byte c2int_digit_from_base(byte ch) { |