History

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.

Michael Matz committed 7 years ago

Commit d72b8771 parent be7c8701 file · +7 −2Browse files

Unified · Split

tccpp.c+7−2
@@ -3625,8 +3625,13 @@ ST_FUNC void preprocess_start(TCCState *s1, int is_asm) · 3624 unmodified lines
3625/* cleanup from error/setjmp */3625/* cleanup from error/setjmp */
3626ST_FUNC void preprocess_end(TCCState *s1)3626ST_FUNC void preprocess_end(TCCState *s1)
3627{3627{
3628 while (macro_stack)3628 /* Normally macro_stack is NULL here, except if an
3629 end_macro();3629 error was thrown; then it can point to allocated storage
3630 or to some stack variables, but those are unwound via
3631 setjmp already, so can't be accessed. Only two choices:
3632 either we leak memory or we access invalid memory. The
3633 former is the better choice. */
3634 macro_stack = NULL;
3630 macro_ptr = NULL;3635 macro_ptr = NULL;
3631}3636}
3632 3637

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t