aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/bif.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2014-11-05 15:27:14 +0100
committerLukas Larsson <[email protected]>2014-11-05 15:27:14 +0100
commit0d18bf3268379df2b91e165a835426db77f015e3 (patch)
tree0f7adb74cf5ee963b95b4581b2c6f82ea039fd5c /erts/emulator/beam/bif.c
parent0c23d76c650e3dca4935aaca2f2ea88b0e9a52ff (diff)
parent7513bb7670cf7081c4b70e240f99f9424b612f0b (diff)
downloadotp-0d18bf3268379df2b91e165a835426db77f015e3.tar.gz
otp-0d18bf3268379df2b91e165a835426db77f015e3.tar.bz2
otp-0d18bf3268379df2b91e165a835426db77f015e3.zip
Merge branch 'maint'
* maint: erts: Fix ub in list_to_integer and bignum div
Diffstat (limited to 'erts/emulator/beam/bif.c')
-rw-r--r--erts/emulator/beam/bif.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index 059f9f6c2c..49996e7f0b 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -2868,6 +2868,7 @@ static int do_list_to_integer(Process *p, Eterm orig_list,
Eterm *integer, Eterm *rest)
{
Sint i = 0;
+ Uint ui = 0;
int skip = 0;
int neg = 0;
int n = 0;
@@ -2921,8 +2922,8 @@ static int do_list_to_integer(Process *p, Eterm orig_list,
unsigned_val(CAR(list_val(lst))) > '9') {
break;
}
- i = i * 10;
- i = i + unsigned_val(CAR(list_val(lst))) - '0';
+ ui = ui * 10;
+ ui = ui + unsigned_val(CAR(list_val(lst))) - '0';
n++;
lst = CDR(list_val(lst));
if (is_nil(lst)) {
@@ -2946,7 +2947,8 @@ static int do_list_to_integer(Process *p, Eterm orig_list,
*/
if (n <= SMALL_DIGITS) { /* It must be small */
- if (neg) i = -i;
+ if (neg) i = -(Sint)ui;
+ else i = (Sint)ui;
res = make_small(i);
} else {
lg2 = (n+1)*230/69+1;