aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_load.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-06-08 07:29:18 +0200
committerBjörn Gustavsson <[email protected]>2011-08-03 11:24:52 +0200
commit903be1a669f9a32858e08f631fabffc00861e739 (patch)
treedfe2e5003b9be52ae5ae53be8770520d5a209cf1 /erts/emulator/beam/beam_load.c
parent2d30edeb73119bbbcf3622e5c163552c10df0861 (diff)
downloadotp-903be1a669f9a32858e08f631fabffc00861e739.tar.gz
otp-903be1a669f9a32858e08f631fabffc00861e739.tar.bz2
otp-903be1a669f9a32858e08f631fabffc00861e739.zip
Fix binary construction with huge literal sizes
Constructing binaries using the bit syntax with literals sizes that would not fit in an Uint will either cause an emulator crash or the loading to be aborted. Use the new TAG_o tag introduced in the previous commit to make sure that the attempt to create huge binary literals will generate a system_limit exception at run-time.
Diffstat (limited to 'erts/emulator/beam/beam_load.c')
-rw-r--r--erts/emulator/beam/beam_load.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index d154c1ff96..eb10ae59a8 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -2527,13 +2527,8 @@ should_gen_heap_bin(LoaderState* stp, GenOpArg Src)
static int
binary_too_big(LoaderState* stp, GenOpArg Size)
{
- return Size.type == TAG_u && ((Size.val >> (8*sizeof(Uint)-3)) != 0);
-}
-
-static int
-binary_too_big_bits(LoaderState* stp, GenOpArg Size)
-{
- return Size.type == TAG_u && (((Size.val+7)/8) >> (8*sizeof(Uint)-3) != 0);
+ return Size.type == TAG_o ||
+ (Size.type == TAG_u && ((Size.val >> (8*sizeof(Uint)-3)) != 0));
}
static GenOp*