diff options
author | Sverker Eriksson <[email protected]> | 2011-09-28 18:21:52 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2011-09-28 18:25:53 +0200 |
commit | 909cc850f3bd3da0e996d500ec1c27d08ad8de1a (patch) | |
tree | d699b3707c3d0b0fa864b7d0ba893625636ef25d | |
parent | b83073436a39553da458b19ef572ded9cd051611 (diff) | |
download | otp-909cc850f3bd3da0e996d500ec1c27d08ad8de1a.tar.gz otp-909cc850f3bd3da0e996d500ec1c27d08ad8de1a.tar.bz2 otp-909cc850f3bd3da0e996d500ec1c27d08ad8de1a.zip |
[erts] Fix memory leak in erts_make_stub_module (hipe loading)
Code area allocation was done twice; first in read_code_header()
and then in erts_make_stub_module() itself.
-rw-r--r-- | erts/emulator/beam/beam_load.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index eb10ae59a8..fceb352cf3 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -635,6 +635,25 @@ bin_load(Process *c_p, ErtsProcLocks c_p_locks, } /* + * Initialize code area. + */ + state.code_buffer_size = erts_next_heap_size(2048 + state.num_functions, 0); + state.code = (BeamInstr *) erts_alloc(ERTS_ALC_T_CODE, + sizeof(BeamInstr) * state.code_buffer_size); + + state.code[MI_NUM_FUNCTIONS] = state.num_functions; + state.ci = MI_FUNCTIONS + state.num_functions + 1; + + state.code[MI_ATTR_PTR] = 0; + state.code[MI_ATTR_SIZE] = 0; + state.code[MI_ATTR_SIZE_ON_HEAP] = 0; + state.code[MI_COMPILE_PTR] = 0; + state.code[MI_COMPILE_SIZE] = 0; + state.code[MI_COMPILE_SIZE_ON_HEAP] = 0; + state.code[MI_NUM_BREAKPOINTS] = 0; + + + /* * Read the atom table. */ @@ -1363,24 +1382,6 @@ read_code_header(LoaderState* stp) #endif } - /* - * Initialize code area. - */ - stp->code_buffer_size = erts_next_heap_size(2048 + stp->num_functions, 0); - stp->code = (BeamInstr *) erts_alloc(ERTS_ALC_T_CODE, - sizeof(BeamInstr) * stp->code_buffer_size); - - stp->code[MI_NUM_FUNCTIONS] = stp->num_functions; - stp->ci = MI_FUNCTIONS + stp->num_functions + 1; - - stp->code[MI_ATTR_PTR] = 0; - stp->code[MI_ATTR_SIZE] = 0; - stp->code[MI_ATTR_SIZE_ON_HEAP] = 0; - stp->code[MI_COMPILE_PTR] = 0; - stp->code[MI_COMPILE_SIZE] = 0; - stp->code[MI_COMPILE_SIZE_ON_HEAP] = 0; - stp->code[MI_NUM_BREAKPOINTS] = 0; - stp->new_bs_put_strings = 0; stp->catches = 0; return 1; |