aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_emu.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-05-10 10:56:24 +0200
committerBjörn Gustavsson <[email protected]>2011-08-03 11:24:52 +0200
commite8becad96454a8deb755f587ca0daaf96dfca90e (patch)
tree40ba945786f497611441f5a13f07efdf2e210879 /erts/emulator/beam/beam_emu.c
parent07936436b8a8b18b80451a09e040283ebecbd43b (diff)
downloadotp-e8becad96454a8deb755f587ca0daaf96dfca90e.tar.gz
otp-e8becad96454a8deb755f587ca0daaf96dfca90e.tar.bz2
otp-e8becad96454a8deb755f587ca0daaf96dfca90e.zip
Fix construction of <<0:((1 bsl 32)-1)>>
Attempting to construct <<0:((1 bsl 32)-1)>>, the largest bitstring allowed in a 32 bit emulator, would cause an emulator crash because of integer overflow. Fix the problem by using an Uint64 to avoid integer overflow. Do not attempt to handle construction of <<0:((1 bsl 64)-1>> in a 64-bit emulator, because that will certainly cause the emulator to terminate anyway because of insufficient memory.
Diffstat (limited to 'erts/emulator/beam/beam_emu.c')
-rw-r--r--erts/emulator/beam/beam_emu.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c
index fb90a7d4f7..937b3d9e53 100644
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -3561,7 +3561,7 @@ void process_main(void)
* Operands: NotUsed Live Dst
*/
do_bs_init_bits_known:
- num_bytes = (num_bits+7) >> 3;
+ num_bytes = ((Uint64)num_bits+(Uint64)7) >> 3;
if (num_bits & 7) {
alloc += ERL_SUB_BIN_SIZE;
}