VLA leaks vstack. added warning to detect future leaks
This commit is contained in:
parent
c94f80502e
commit
6eb97c70b7
1 changed files with 4 additions and 0 deletions
4
libtcc.c
4
libtcc.c
|
|
@ -689,6 +689,7 @@ ST_FUNC int tcc_open(TCCState *s1, const char *filename)
|
||||||
static int tcc_compile(TCCState *s1)
|
static int tcc_compile(TCCState *s1)
|
||||||
{
|
{
|
||||||
Sym *define_start;
|
Sym *define_start;
|
||||||
|
SValue *pvtop;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
volatile int section_sym;
|
volatile int section_sym;
|
||||||
|
|
||||||
|
|
@ -758,6 +759,7 @@ static int tcc_compile(TCCState *s1)
|
||||||
|
|
||||||
define_start = define_stack;
|
define_start = define_stack;
|
||||||
nocode_wanted = 1;
|
nocode_wanted = 1;
|
||||||
|
pvtop = vtop;
|
||||||
|
|
||||||
if (setjmp(s1->error_jmp_buf) == 0) {
|
if (setjmp(s1->error_jmp_buf) == 0) {
|
||||||
s1->nb_errors = 0;
|
s1->nb_errors = 0;
|
||||||
|
|
@ -787,6 +789,8 @@ static int tcc_compile(TCCState *s1)
|
||||||
|
|
||||||
sym_pop(&global_stack, NULL);
|
sym_pop(&global_stack, NULL);
|
||||||
sym_pop(&local_stack, NULL);
|
sym_pop(&local_stack, NULL);
|
||||||
|
if (pvtop != vtop)
|
||||||
|
warning("internal compiler error: vstack leak? (%d)", vtop - pvtop);
|
||||||
|
|
||||||
return s1->nb_errors != 0 ? -1 : 0;
|
return s1->nb_errors != 0 ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue