Skip to content

Commit

Permalink
Merge pull request #1658 from MoarVM/fix_segfault_after_capture_repla…
Browse files Browse the repository at this point in the history
…ce_literal_arg

Fix segfault after capture-replace-literal-arg with different kind
  • Loading branch information
niner committed Feb 1, 2022
2 parents 3ff5b11 + 2abb469 commit ac0dee7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/6model/reprs/MVMCapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ MVMObject * MVM_capture_replace_arg(MVMThreadContext *tc, MVMObject *capture_obj
* The callsite MUST be created after we allocated as it may contain named
* arguments, i.e. contain pointers to strings which wouldn't get marked. */
MVMCallsite *callsite = capture->body.callsite;
MVMCallsite *new_callsite = MVM_callsite_replace_positional(tc, capture->body.callsite, idx, kind);
if ((callsite->arg_flags[idx] & MVM_CALLSITE_ARG_TYPE_MASK) != kind)
MVM_exception_throw_adhoc(tc, "Cannot replace capture argument with different kind %d -> %d", callsite->arg_flags[idx], kind);

MVMCallsite *new_callsite = MVM_callsite_replace_positional(tc, callsite, idx, kind);
new_callsite->arg_flags[idx] = kind;

/* Form a new arguments buffer, replacing the specified argument. */
Expand Down

0 comments on commit ac0dee7

Please sign in to comment.