when an error is thrown macro_stack might point to unwound local variables, we can't access them.
Unified · Split
| @@ -3625,8 +3625,13 @@ ST_FUNC void preprocess_start(TCCState *s1, int is_asm) · 3624 unmodified lines | ||
| 3625 | 3625 | /* cleanup from error/setjmp */ |
| 3626 | 3626 | ST_FUNC void preprocess_end(TCCState *s1) |
| 3627 | 3627 | { |
| 3628 | − while (macro_stack) | |
| 3629 | − end_macro(); | |
| 3628 | + /* Normally macro_stack is NULL here, except if an | |
| 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 | 3635 | macro_ptr = NULL; |
| 3631 | 3636 | } |
| 3632 | 3637 | |