aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/big.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-09-03 20:22:42 +0200
committerSverker Eriksson <[email protected]>2014-09-04 17:33:22 +0200
commit21e4cf5b378ed378296a544d0ad8da08cf95700e (patch)
tree4b248f4e232cc9658767b9b15b5aa4ac85fef2d4 /erts/emulator/beam/big.c
parent9de7cc7f881b5df18d0a26f7d37af164bc0c390e (diff)
downloadotp-21e4cf5b378ed378296a544d0ad8da08cf95700e.tar.gz
otp-21e4cf5b378ed378296a544d0ad8da08cf95700e.tar.bz2
otp-21e4cf5b378ed378296a544d0ad8da08cf95700e.zip
erts: Correct conversion of MIN_SMALL numeral to fixnum
list_to_integer and binary_to_integer returned un-normalized bignum for -134217728 on 32-bit and -576460752303423488 on 64-bit. Thanks to Jesper Louis Andersen, Mikael Pettersson and Anthony Ramine for report, initial patch and optimization suggestion.
Diffstat (limited to 'erts/emulator/beam/big.c')
-rw-r--r--erts/emulator/beam/big.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/erts/emulator/beam/big.c b/erts/emulator/beam/big.c
index e62caa6b22..a8710dd910 100644
--- a/erts/emulator/beam/big.c
+++ b/erts/emulator/beam/big.c
@@ -2675,9 +2675,6 @@ Eterm erts_chars_to_integer(Process *BIF_P, char *bytes,
res = big_plus_small(res, m, hp);
}
- if (is_big(res)) /* check if small */
- res = big_plus_small(res, 0, hp); /* includes conversion to small */
-
if (neg) {
if (is_small(res))
res = make_small(-signed_val(res));
@@ -2687,8 +2684,12 @@ Eterm erts_chars_to_integer(Process *BIF_P, char *bytes,
}
}
- if (is_big(res)) {
- hp += (big_arity(res) + 1);
+ if (is_not_small(res)) {
+ res = big_plus_small(res, 0, hp); /* includes conversion to small */
+
+ if (is_not_small(res)) {
+ hp += (big_arity(res) + 1);
+ }
}
HRelease(BIF_P, hp_end, hp);
goto bytebuf_to_integer_1_done;