Reset members of jit block/value stack after destroy (#1048)

After `jit_value_stack_destory()`, the `JitValue` pointed
by `value_list_head` and `value_list_end` are freed and
still keep the value.

So, when `jit_value_stack_push()` is called, for example,
`load_block_params()` after `jit_value_stack_destroy()` in
`handle_op_else()`, `value_stack` will not be treated like
an empty one, and new `JitValue` will be appended to `value_list_end`,
which is a dangling pointer(pointer to the freed `JitValue`).
This commit is contained in:
liang.he 2022-03-15 20:10:48 +08:00 committed by GitHub
parent eb518c0423
commit 9fd3d53bc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1330,6 +1330,9 @@ jit_value_stack_destroy(JitValueStack *stack)
jit_free(value);
value = p;
}
stack->value_list_head = NULL;
stack->value_list_end = NULL;
}
void
@ -1373,6 +1376,9 @@ jit_block_stack_destroy(JitBlockStack *stack)
jit_block_destroy(block);
block = p;
}
stack->block_list_head = NULL;
stack->block_list_end = NULL;
}
bool