mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 06:55:07 +00:00
Remove unused block_addr_cache buffer in wasm loader (#493)
And fix possible memory leak issue in aot loader when apply relocation failed. Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
parent
788cbf2a19
commit
8a477786f1
|
@ -1584,11 +1584,11 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
|
|||
#endif
|
||||
) {
|
||||
if (!do_text_relocation(module, group, error_buf, error_buf_size))
|
||||
return false;
|
||||
goto fail;
|
||||
}
|
||||
else {
|
||||
if (!do_data_relocation(module, group, error_buf, error_buf_size))
|
||||
return false;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2518,7 +2518,6 @@ fail:
|
|||
|
||||
static bool
|
||||
wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
|
||||
BlockAddr *block_addr_cache,
|
||||
char *error_buf, uint32 error_buf_size);
|
||||
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
|
@ -2542,9 +2541,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
uint32 aux_stack_top = (uint32)-1, global_index, func_index, i;
|
||||
uint32 aux_data_end_global_index = (uint32)-1;
|
||||
uint32 aux_heap_base_global_index = (uint32)-1;
|
||||
BlockAddr *block_addr_cache;
|
||||
WASMType *func_type;
|
||||
uint64 total_size;
|
||||
|
||||
/* Find code and function sections if have */
|
||||
while (section) {
|
||||
|
@ -2828,23 +2825,13 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
handle_table = wasm_interp_get_handle_table();
|
||||
#endif
|
||||
|
||||
total_size = sizeof(BlockAddr) * (uint64)BLOCK_ADDR_CACHE_SIZE
|
||||
* BLOCK_ADDR_CONFLICT_SIZE;
|
||||
if (!(block_addr_cache = loader_malloc
|
||||
(total_size, error_buf, error_buf_size))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < module->function_count; i++) {
|
||||
WASMFunction *func = module->functions[i];
|
||||
memset(block_addr_cache, 0, (uint32)total_size);
|
||||
if (!wasm_loader_prepare_bytecode(module, func, block_addr_cache,
|
||||
if (!wasm_loader_prepare_bytecode(module, func,
|
||||
error_buf, error_buf_size)) {
|
||||
wasm_runtime_free(block_addr_cache);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
wasm_runtime_free(block_addr_cache);
|
||||
|
||||
if (!module->possible_memory_grow) {
|
||||
WASMMemoryImport *memory_import;
|
||||
|
@ -5692,7 +5679,6 @@ fail:
|
|||
|
||||
static bool
|
||||
wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
|
||||
BlockAddr *block_addr_cache,
|
||||
char *error_buf, uint32 error_buf_size)
|
||||
{
|
||||
uint8 *p = func->code, *p_end = func->code + func->code_size, *p_org;
|
||||
|
|
Loading…
Reference in New Issue
Block a user