From: Wolfgang (Blub) Bumiller Date: Fri, 16 Nov 2012 20:27:15 +0000 (+0100) Subject: Fix a bug in macro call parameter parsing X-Git-Tag: 0.1.9~404^2~39 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7e660951c2086d51a154fd0fff367fb377038cf1;p=xonotic%2Fgmqcc.git Fix a bug in macro call parameter parsing --- diff --git a/ftepp.c b/ftepp.c index ec5c3f6..fe3b783 100644 --- a/ftepp.c +++ b/ftepp.c @@ -313,7 +313,7 @@ static bool ftepp_macro_call_params(ftepp_t *ftepp, macroparam **out_params) size_t parens = 0; size_t i; - while (true) { + while (ftepp->token != ')') { mp.tokens = NULL; while (parens || ftepp->token != ',') { if (ftepp->token == '(') @@ -386,6 +386,15 @@ static bool ftepp_macro_call(ftepp_t *ftepp, ppmacro *macro) if (!ftepp_macro_call_params(ftepp, ¶ms)) return false; + if (vec_size(params) != vec_size(macro->params)) { + ftepp_error(ftepp, "macro %s expects %u paramteters, %u provided", macro->name, + (unsigned int)vec_size(macro->params), + (unsigned int)vec_size(params)); + retval = false; + goto cleanup; + } + + ftepp_out(ftepp, "Parsed macro parameters", false); goto cleanup;