diff options
author | Björn Gustavsson <[email protected]> | 2011-02-24 08:34:42 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2011-02-24 08:34:42 +0100 |
commit | d4ea1aa8d1a206e7a143ac4bd9bd6c37c7fccdaa (patch) | |
tree | f84ec3fa4c332f27dc997507d510c42e83f046f0 /erts/emulator/beam/beam_load.c | |
parent | 8592a7629a4afd1ea5b19f7473b3b06605169e66 (diff) | |
parent | e1833ee82c7a07e000dbbea3af6c8fefc02582d6 (diff) | |
download | otp-d4ea1aa8d1a206e7a143ac4bd9bd6c37c7fccdaa.tar.gz otp-d4ea1aa8d1a206e7a143ac4bd9bd6c37c7fccdaa.tar.bz2 otp-d4ea1aa8d1a206e7a143ac4bd9bd6c37c7fccdaa.zip |
Merge branch 'bjorn/erts/minor-fixes' into dev
* bjorn/erts/minor-fixes:
BEAM loader: Add an assertion to check for overflowed code space
beam_emu: Eliminate redundant #ifdef
beam_emu: Remove unnecessary decrement of I in "case_end r"
Diffstat (limited to 'erts/emulator/beam/beam_load.c')
-rw-r--r-- | erts/emulator/beam/beam_load.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index 4e0d19dafa..788cb4209c 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -3770,25 +3770,32 @@ freeze_code(LoaderState* stp) CHKBLK(ERTS_ALC_T_CODE,code); if (compile_size) { byte* compile_info = str_table + strtab_size + attr_size; - CHKBLK(ERTS_ALC_T_CODE,code); + CHKBLK(ERTS_ALC_T_CODE,code); sys_memcpy(compile_info, stp->chunks[COMPILE_CHUNK].start, stp->chunks[COMPILE_CHUNK].size); - CHKBLK(ERTS_ALC_T_CODE,code); + + CHKBLK(ERTS_ALC_T_CODE,code); code[MI_COMPILE_PTR] = (BeamInstr) compile_info; - CHKBLK(ERTS_ALC_T_CODE,code); + CHKBLK(ERTS_ALC_T_CODE,code); code[MI_COMPILE_SIZE] = (BeamInstr) stp->chunks[COMPILE_CHUNK].size; - CHKBLK(ERTS_ALC_T_CODE,code); + CHKBLK(ERTS_ALC_T_CODE,code); decoded_size = erts_decode_ext_size(compile_info, compile_size, 0); - CHKBLK(ERTS_ALC_T_CODE,code); + CHKBLK(ERTS_ALC_T_CODE,code); if (decoded_size < 0) { LoadError0(stp, "bad external term representation of compilation information"); } - CHKBLK(ERTS_ALC_T_CODE,code); + CHKBLK(ERTS_ALC_T_CODE,code); code[MI_COMPILE_SIZE_ON_HEAP] = decoded_size; } CHKBLK(ERTS_ALC_T_CODE,code); /* + * Make sure that we have not overflowed the allocated code space. + */ + ASSERT(str_table + strtab_size + attr_size + compile_size == + ((byte *) code) + size); + + /* * Go through all i_new_bs_put_strings instructions, restore the pointer to * the instruction and convert string offsets to pointers (to the * FIRST character). |