diff options
author | Lukas Larsson <[email protected]> | 2014-09-22 12:00:05 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2014-09-22 16:02:05 +0200 |
commit | 16d8a6ce56fd066efa9ecb1d3fa3b3dab6d9613c (patch) | |
tree | f9c026a433fd0a620e04a9741882da1b129fa7b4 /erts/emulator/beam/big.c | |
parent | 743ed31108ee555db18d9833186865e85e34333e (diff) | |
download | otp-16d8a6ce56fd066efa9ecb1d3fa3b3dab6d9613c.tar.gz otp-16d8a6ce56fd066efa9ecb1d3fa3b3dab6d9613c.tar.bz2 otp-16d8a6ce56fd066efa9ecb1d3fa3b3dab6d9613c.zip |
erts: Fix ub in list_to_integer and bignum div
Diffstat (limited to 'erts/emulator/beam/big.c')
-rw-r--r-- | erts/emulator/beam/big.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/erts/emulator/beam/big.c b/erts/emulator/beam/big.c index a8710dd910..de7d370938 100644 --- a/erts/emulator/beam/big.c +++ b/erts/emulator/beam/big.c @@ -274,10 +274,9 @@ _b = _b << _s; \ _vn1 = _b >> H_EXP; \ _vn0 = _b & LO_MASK; \ - /* Sometimes _s is 0 which triggers undefined behaviour for the \ - (_a0>>(D_EXP-_s)) shift, but this is ok because the \ - & -s will make it all to 0 later anyways. */ \ - _un32 = (_a1 << _s) | ((_a0>>(D_EXP-_s)) & (-_s >> (D_EXP-1))); \ + /* If needed to avoid undefined behaviour */ \ + if (_s) _un32 = (_a1 << _s) | ((_a0>>(D_EXP-_s)) & (-_s >> (D_EXP-1))); \ + else _un32 = _a1; \ _un10 = _a0 << _s; \ _un1 = _un10 >> H_EXP; \ _un0 = _un10 & LO_MASK; \ |