]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ftepp.c
fix a leak: delete the output string of macro calls
[xonotic/gmqcc.git] / ftepp.c
diff --git a/ftepp.c b/ftepp.c
index 6d5026479807434c98e0af53ec52ea8c3428bad7..10c945ecd9a666c030ee454792483e7978f3b30b 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012
+ * Copyright (C) 2012, 2013
  *     Wolfgang Bumiller
  *     Dale Weiler 
  *
@@ -234,6 +234,7 @@ static ftepp_t* ftepp_new()
 static void ftepp_delete(ftepp_t *self)
 {
     size_t i;
+    ftepp_flush(self);
     if (self->itemname)
         mem_d(self->itemname);
     if (self->includename)
@@ -646,13 +647,18 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param
         goto cleanup;
     }
     ftepp->output_string = old_string;
+    inlex->line = ftepp->lex->line;
+    inlex->sline = ftepp->lex->sline;
     ftepp->lex = inlex;
     ftepp_recursion_header(ftepp);
     if (!ftepp_preprocess(ftepp)) {
+        vec_free(ftepp->lex->open_string);
+        old_string = ftepp->output_string;
         lex_close(ftepp->lex);
         retval = false;
         goto cleanup;
     }
+    vec_free(ftepp->lex->open_string);
     ftepp_recursion_footer(ftepp);
     old_string = ftepp->output_string;