]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Fix a bug in macro call parameter parsing
authorWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 16 Nov 2012 20:27:15 +0000 (21:27 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 16 Nov 2012 20:27:15 +0000 (21:27 +0100)
ftepp.c

diff --git a/ftepp.c b/ftepp.c
index ec5c3f648af3eb89ceb2f4743f3e3c0b6f59b2d5..fe3b783453762ec73b8f988f5c99d834f864d96b 100644 (file)
--- 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, &params))
         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;