wpp: Free some filename strings after processing an include (Valgrind).
This commit is contained in:
parent
18a416f7d5
commit
1b79df4e80
|
@ -213,7 +213,7 @@ typedef struct bufferstackentry {
|
|||
pp_entry_t *define; /* Points to expanding define or NULL if handling includes */
|
||||
int line_number; /* Line that we were handling */
|
||||
int char_number; /* The current position on that line */
|
||||
const char *filename; /* Filename that we were handling */
|
||||
char *filename; /* Filename that we were handling */
|
||||
int if_depth; /* How many #if:s deep to check matching #endif:s */
|
||||
int ncontinuations; /* Remember the continuation state */
|
||||
int should_pop; /* Set if we must pop the start-state on EOF */
|
||||
|
@ -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,17 +1368,21 @@ 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 (bufferstack[bufferstackidx].include_filename)
|
||||
{
|
||||
free(pp_status.input);
|
||||
pp_status.input = bufferstack[bufferstackidx].filename;
|
||||
}
|
||||
pp_status.line_number = bufferstack[bufferstackidx].line_number;
|
||||
pp_status.char_number = bufferstack[bufferstackidx].char_number;
|
||||
pp_status.input = bufferstack[bufferstackidx].filename;
|
||||
ncontinuations = bufferstack[bufferstackidx].ncontinuations;
|
||||
if (!iep)
|
||||
free(bufferstack[bufferstackidx].include_filename);
|
||||
}
|
||||
|
||||
if(ppy_debug)
|
||||
|
|
|
@ -206,7 +206,7 @@ int wpp_parse( const char *input, FILE *output )
|
|||
return 2;
|
||||
}
|
||||
|
||||
pp_status.input = input;
|
||||
pp_status.input = input ? pp_xstrdup(input) : NULL;
|
||||
|
||||
ppy_out = output;
|
||||
pp_writestring("# 1 \"%s\" 1\n", input ? input : "");
|
||||
|
@ -215,7 +215,11 @@ int wpp_parse( const char *input, FILE *output )
|
|||
/* If there were errors during processing, return an error code */
|
||||
if (!ret && pp_status.state) ret = pp_status.state;
|
||||
|
||||
if (input) wpp_callbacks->close(pp_status.file);
|
||||
if (input)
|
||||
{
|
||||
wpp_callbacks->close(pp_status.file);
|
||||
free(pp_status.input);
|
||||
}
|
||||
/* Clean if_stack, it could remain dirty on errors */
|
||||
while (pp_get_if_depth()) pp_pop_if();
|
||||
del_special_defines();
|
||||
|
|
|
@ -228,7 +228,7 @@ void pp_internal_error(const char *file, int line, const char *s, ...) __attribu
|
|||
/* everything is in this structure to avoid polluting the global symbol space */
|
||||
struct pp_status
|
||||
{
|
||||
const char *input; /* current input file name */
|
||||
char *input; /* current input file name */
|
||||
void *file; /* current input file descriptor */
|
||||
int line_number; /* current line number */
|
||||
int char_number; /* current char number in line */
|
||||
|
|
Loading…
Reference in New Issue