aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2015-03-27 16:47:23 +0100
committerSverker Eriksson <[email protected]>2015-03-27 16:47:23 +0100
commitcbceea683c9f718bc6f0140c2402a7f74455ea14 (patch)
tree1d10b24da3fedc272b39d7293aa45d2c33eb53c1 /erts/emulator/beam
parentd477e5978d165d7496fa6b983f8933f5105f901f (diff)
parent59ec3041469226ef65894e5774ecac0fea1551cd (diff)
downloadotp-cbceea683c9f718bc6f0140c2402a7f74455ea14.tar.gz
otp-cbceea683c9f718bc6f0140c2402a7f74455ea14.tar.bz2
otp-cbceea683c9f718bc6f0140c2402a7f74455ea14.zip
Merge branch 'sverk/large-list_to_integer-bug/OTP-12624' into maint
* sverk/large-list_to_integer-bug/OTP-12624: erts: Fix bug in list_to_integer for very large strings
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/bif.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index 5ac74032fa..b43137597e 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -2775,7 +2775,7 @@ static int do_list_to_integer(Process *p, Eterm orig_list,
Uint ui = 0;
int skip = 0;
int neg = 0;
- int n = 0;
+ Sint n = 0;
int m;
int lg2;
Eterm res;
@@ -2855,7 +2855,9 @@ static int do_list_to_integer(Process *p, Eterm orig_list,
else i = (Sint)ui;
res = make_small(i);
} else {
- lg2 = (n+1)*230/69+1;
+ /* Convert from log10 to log2 by multiplying with 1/log10(2)=3.3219
+ which we round up to (3 + 1/3) */
+ lg2 = (n+1)*3 + (n+1)/3 + 1;
m = (lg2+D_EXP-1)/D_EXP; /* number of digits */
m = BIG_NEED_SIZE(m); /* number of words + thing */