Skip to content

Commit

Permalink
Make MVM_args_proc_cleanup idempotent
Browse files Browse the repository at this point in the history
So that even if we do somehow end up calling it twice somehow, we'll
never risk a double free. It's rare that we end up with so many named
arguments that we need this buffer anyway, so the zeroing is no real
loss.
  • Loading branch information
jnthn committed Oct 26, 2021
1 parent 9266e79 commit fd57161
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/core/args.h
Expand Up @@ -68,9 +68,11 @@ MVM_STATIC_INLINE void MVM_args_proc_setup(MVMThreadContext *tc, MVMArgProcConte

/* Clean up an arguments processing context. */
MVM_STATIC_INLINE void MVM_args_proc_cleanup(MVMThreadContext *tc, MVMArgProcContext *ctx) {
if (ctx->named_used_size > 64)
if (ctx->named_used_size > 64) {
MVM_fixed_size_free(tc, tc->instance->fsa, ctx->named_used_size,
ctx->named_used.byte_array);
ctx->named_used_size = 0;
}
}

/* Argument processing context handling. */
Expand Down
3 changes: 1 addition & 2 deletions src/core/frame.c
Expand Up @@ -128,8 +128,7 @@ static void instrumentation_level_barrier(MVMThreadContext *tc, MVMStaticFrame *
* part of a continuation that was taken but never invoked, we should check
* things normally cleaned up on return don't need cleaning up also. */
void MVM_frame_destroy(MVMThreadContext *tc, MVMFrame *frame) {
if (frame->work)
MVM_args_proc_cleanup(tc, &frame->params);
MVM_args_proc_cleanup(tc, &frame->params);
if (frame->env && !MVM_FRAME_IS_ON_CALLSTACK(tc, frame))
MVM_fixed_size_free(tc, tc->instance->fsa, frame->allocd_env, frame->env);
if (frame->extra) {
Expand Down

0 comments on commit fd57161

Please sign in to comment.