Skip to content

Commit

Permalink
bugzilla 3495 Segfault(typinf.c) instantiating D variadic function wi…
Browse files Browse the repository at this point in the history
…th too few arguments
  • Loading branch information
Walter Bright committed Dec 3, 2009
1 parent 57e26ae commit 23025ef
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ void functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argum
if (tf->varargs == 2 && i + 1 == nparams)
goto L2;
error(loc, "expected %zu function arguments, not %zu", nparams, nargs);
break;
return;
}
arg = p->defaultArg;
#if DMDV2
Expand All @@ -670,7 +670,9 @@ void functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argum
if (arg->implicitConvTo(p->type))
{
if (nargs != nparams)
error(loc, "expected %zu function arguments, not %zu", nparams, nargs);
{ error(loc, "expected %zu function arguments, not %zu", nparams, nargs);
return;
}
goto L1;
}
L2:
Expand Down Expand Up @@ -881,9 +883,8 @@ void functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argum
// If D linkage and variadic, add _arguments[] as first argument
if (tf->linkage == LINKd && tf->varargs == 1)
{
Expression *e;

e = createTypeInfoArray(sc, (Expression **)&arguments->data[nparams],
assert(arguments->dim >= nparams);
Expression *e = createTypeInfoArray(sc, (Expression **)&arguments->data[nparams],
arguments->dim - nparams);
arguments->insert(0, e);
}
Expand Down

0 comments on commit 23025ef

Please sign in to comment.