[PATCH 5/5] wpp: Free some filename strings after processing an include (Valgrind). (try 2)

Matteo Bruni mbruni at codeweavers.com
Wed May 14 09:12:41 CDT 2014


This time without widl segfaulting hopefully...
---
 libs/wpp/ppl.l | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libs/wpp/ppl.l b/libs/wpp/ppl.l
index 0c0d2fd..78f0b35 100644
--- a/libs/wpp/ppl.l
+++ b/libs/wpp/ppl.l
@@ -1340,6 +1340,8 @@ static bufferstackentry_t *pop_buffer(void)
 		bufferstack[bufferstackidx].define->expanding = 0;
 	else
 	{
+		includelogicentry_t *iep = NULL;
+
 		if(!bufferstack[bufferstackidx].should_pop)
 		{
 			wpp_callbacks->close(pp_status.file);
@@ -1351,7 +1353,7 @@ static bufferstackentry_t *pop_buffer(void)
 				pp_entry_t *ppp = pplookup(pp_incl_state.ppp);
 				if(ppp)
 				{
-					includelogicentry_t *iep = pp_xmalloc(sizeof(includelogicentry_t));
+					iep = pp_xmalloc(sizeof(includelogicentry_t));
 					if(!iep)
 						return NULL;
 
@@ -1366,13 +1368,15 @@ static bufferstackentry_t *pop_buffer(void)
 					if(pp_status.debug)
 						fprintf(stderr, "pop_buffer: %s:%d: includelogic added, include_ppp='%s', file='%s'\n", bufferstack[bufferstackidx].filename, bufferstack[bufferstackidx].line_number, pp_incl_state.ppp, iep->filename);
 				}
-				else
-					free(bufferstack[bufferstackidx].include_filename);
 			}
 			free(pp_incl_state.ppp);
 			pp_incl_state	= bufferstack[bufferstackidx].incl;
 
 		}
+		if (!iep)
+			free(bufferstack[bufferstackidx].include_filename);
+		if (pp_status.input != bufferstack[bufferstackidx].filename)
+			free((void *)pp_status.input);
 		pp_status.line_number = bufferstack[bufferstackidx].line_number;
 		pp_status.char_number = bufferstack[bufferstackidx].char_number;
 		pp_status.input  = bufferstack[bufferstackidx].filename;
-- 
1.8.5.5




More information about the wine-patches mailing list