wpp: Assure if_stack is clean before returning.

Matteo Bruni matteo.mystral at gmail.com
Thu Feb 4 12:22:57 CST 2010


If the file to be preprocessed has syntax errors such as #ifdef/#endif
mismatches, at the end of the parsing the if_stack array may not be
empty. This could create problems on following wpp_parse calls
(probably this is an issue only for the shader assembler and not for
the command line tools).
-------------- next part --------------
From 42773b9c003b064bad951731414992b0e35eabe1 Mon Sep 17 00:00:00 2001
From: Matteo Bruni <matteo.mystral at gmail.com>
Date: Thu, 4 Feb 2010 18:56:52 +0100
Subject: wpp: Assure if_stack is clean before returning.

---
 libs/wpp/wpp.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libs/wpp/wpp.c b/libs/wpp/wpp.c
index 47989f1..de4286f 100644
--- a/libs/wpp/wpp.c
+++ b/libs/wpp/wpp.c
@@ -193,9 +193,11 @@ int wpp_parse( const char *input, FILE *output )
 
     ret = ppy_parse();
     /* If there were errors during processing, return an error code */
-    if(!ret && pp_status.state) ret = pp_status.state;
+    if (!ret && pp_status.state) ret = pp_status.state;
 
     if (input) wpp_callbacks->close(pp_status.file);
+    /* Clean if_stack, it could remain dirty on errors */
+    while (pp_get_if_depth()) pp_pop_if();
     pp_pop_define_state();
     return ret;
 }
-- 
1.6.4.4


More information about the wine-patches mailing list