Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created March 14, 2014 20:43
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/619fb15326bebd9dc250 to your computer and use it in GitHub Desktop.
Save jnthn/619fb15326bebd9dc250 to your computer and use it in GitHub Desktop.
diff --git a/src/core/args.c b/src/core/args.c
index 788ac7f..2534e1a 100644
--- a/src/core/args.c
+++ b/src/core/args.c
@@ -62,8 +62,9 @@ void MVM_args_proc_cleanup(MVMThreadContext *tc, MVMArgProcContext *ctx) {
MVMCallsite * MVM_args_proc_to_callsite(MVMThreadContext *tc, MVMArgProcContext *ctx) {
if (ctx->arg_flags) {
MVMCallsite *res = malloc(sizeof(MVMCallsite));
- MVMCallsiteEntry *flags = ctx->arg_count ? malloc(ctx->arg_count) : NULL;
- memcpy(flags, ctx->arg_flags, ctx->arg_count);
+ MVMint32 fsize = ctx->num_pos + (ctx->arg_count - ctx->num_pos) / 2;
+ MVMCallsiteEntry *flags = fsize ? malloc(fsize) : NULL;
+ memcpy(flags, ctx->arg_flags, fsize);
res->arg_flags = flags;
res->arg_count = ctx->arg_count;
res->num_pos = ctx->num_pos;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment