diff options
author | Sverker Eriksson <[email protected]> | 2014-09-03 20:22:42 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2014-09-04 17:33:22 +0200 |
commit | 21e4cf5b378ed378296a544d0ad8da08cf95700e (patch) | |
tree | 4b248f4e232cc9658767b9b15b5aa4ac85fef2d4 /erts/emulator/beam/bif.c | |
parent | 9de7cc7f881b5df18d0a26f7d37af164bc0c390e (diff) | |
download | otp-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/bif.c')
-rw-r--r-- | erts/emulator/beam/bif.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c index fcbeb6cf5c..b835946729 100644 --- a/erts/emulator/beam/bif.c +++ b/erts/emulator/beam/bif.c @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 1996-2013. All Rights Reserved. + * Copyright Ericsson AB 1996-2014. All Rights Reserved. * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in @@ -2887,9 +2887,6 @@ static int do_list_to_integer(Process *p, Eterm orig_list, 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)); @@ -2899,8 +2896,12 @@ static int do_list_to_integer(Process *p, Eterm orig_list, } } - 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(p,hp_end,hp); } |