Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created April 13, 2014 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnthn/10583405 to your computer and use it in GitHub Desktop.
Save jnthn/10583405 to your computer and use it in GitHub Desktop.
diff --git a/src/core/frame.c b/src/core/frame.c
index 21d2309..9c8528b 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -961,10 +961,11 @@ static MVMObject * find_invokee_internal(MVMThreadContext *tc, MVMObject *code,
*tweak_cs = orig->with_invocant;
}
else {
- MVMCallsite *new = malloc(sizeof(MVMCallsite));
- new->arg_flags = malloc((orig->arg_count + 1) * sizeof(MVMCallsiteEntry));
- new->arg_flags[0] = MVM_CALLSITE_ARG_OBJ;
- memcpy(new->arg_flags + 1, orig->arg_flags, orig->arg_count);
+ MVMCallsite *new = malloc(sizeof(MVMCallsite));
+ MVMint32 fsize = orig->num_pos + (orig->arg_count - orig->num_pos) / 2;
+ new->arg_flags = malloc((fsize + 1) * sizeof(MVMCallsiteEntry));
+ new->arg_flags[0] = MVM_CALLSITE_ARG_OBJ;
+ memcpy(new->arg_flags + 1, orig->arg_flags, fsize);
new->arg_count = orig->arg_count + 1;
new->num_pos = orig->num_pos + 1;
new->has_flattening = orig->has_flattening;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment