Fix invalid memory access in preprocess_end
when an error is thrown macro_stack might point to unwound local variables, we can't access them.
This commit is contained in:
parent
be7c870718
commit
d72b877e45
1 changed files with 7 additions and 2 deletions
9
tccpp.c
9
tccpp.c
|
@ -3625,8 +3625,13 @@ ST_FUNC void preprocess_start(TCCState *s1, int is_asm)
|
||||||
/* cleanup from error/setjmp */
|
/* cleanup from error/setjmp */
|
||||||
ST_FUNC void preprocess_end(TCCState *s1)
|
ST_FUNC void preprocess_end(TCCState *s1)
|
||||||
{
|
{
|
||||||
while (macro_stack)
|
/* Normally macro_stack is NULL here, except if an
|
||||||
end_macro();
|
error was thrown; then it can point to allocated storage
|
||||||
|
or to some stack variables, but those are unwound via
|
||||||
|
setjmp already, so can't be accessed. Only two choices:
|
||||||
|
either we leak memory or we access invalid memory. The
|
||||||
|
former is the better choice. */
|
||||||
|
macro_stack = NULL;
|
||||||
macro_ptr = NULL;
|
macro_ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue