ast_call_check_types should not check more parameters than actually available in both the call and the function type - fixes a crash introduced by this on variadic functions

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-10-29 14:35:50 +01:00
parent 6126db10df
commit bd739528ad

5
ast.c
View file

@ -675,8 +675,11 @@ bool ast_call_check_types(ast_call *self)
size_t i; size_t i;
bool retval = true; bool retval = true;
const ast_expression *func = self->func; const ast_expression *func = self->func;
size_t count = self->params_count;
if (count > func->expression.params_count)
count = func->expression.params_count;
for (i = 0; i < self->params_count; ++i) { for (i = 0; i < count; ++i) {
if (!ast_compare_type(self->params[i], (ast_expression*)(func->expression.params[i]))) { if (!ast_compare_type(self->params[i], (ast_expression*)(func->expression.params[i]))) {
asterror(ast_ctx(self), "invalid type for parameter %u in function call", asterror(ast_ctx(self), "invalid type for parameter %u in function call",
(unsigned int)(i+1)); (unsigned int)(i+1));