mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-10-24 18:01:16 +00:00
Prevent BuildPhi from encountering a null llvm_entry_block (#4663)
There is a scenario where `aot_compile_op_block()` does not prepare a block for `if`. As a result, the return value of `LLVMBuildPhi()` in `push_aot_block_to_stack_and_pass_params()` will be dangling, leading to a memory leak as it cannot be released.
This commit is contained in:
parent
163acd2259
commit
826ae6eb01
|
|
@ -495,16 +495,18 @@ push_aot_block_to_stack_and_pass_params(AOTCompContext *comp_ctx,
|
|||
|
||||
/* Create param phis */
|
||||
for (i = 0; i < block->param_count; i++) {
|
||||
if (block->llvm_entry_block) {
|
||||
SET_BUILDER_POS(block->llvm_entry_block);
|
||||
snprintf(name, sizeof(name), "%s%d_phi%d",
|
||||
block_name_prefix[block->label_type], block->block_index,
|
||||
i);
|
||||
block_name_prefix[block->label_type],
|
||||
block->block_index, i);
|
||||
if (!(block->param_phis[i] = LLVMBuildPhi(
|
||||
comp_ctx->builder, TO_LLVM_TYPE(block->param_types[i]),
|
||||
name))) {
|
||||
comp_ctx->builder,
|
||||
TO_LLVM_TYPE(block->param_types[i]), name))) {
|
||||
aot_set_last_error("llvm build phi failed.");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (block->label_type == LABEL_TYPE_IF
|
||||
&& !block->skip_wasm_code_else && block->llvm_else_block) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user