aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Soroka <gits@joesoroka.com>2011-04-08 00:41:55 -0700
committerJoe Soroka <gits@joesoroka.com>2011-04-08 00:41:55 -0700
commit6eb97c70b70444185cdd46c859726a0af0fa2c87 (patch)
treea7377aab3d63f32807d502f7fb9442fcc2247b79
parentc94f80502e0bfd0aa36ca616f299ce85212cb884 (diff)
downloadtinycc-6eb97c70b70444185cdd46c859726a0af0fa2c87.tar.gz
tinycc-6eb97c70b70444185cdd46c859726a0af0fa2c87.tar.bz2
VLA leaks vstack. added warning to detect future leaks
-rw-r--r--libtcc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libtcc.c b/libtcc.c
index 3ce378d..2f77721 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -689,6 +689,7 @@ ST_FUNC int tcc_open(TCCState *s1, const char *filename)
static int tcc_compile(TCCState *s1)
{
Sym *define_start;
+ SValue *pvtop;
char buf[512];
volatile int section_sym;
@@ -758,6 +759,7 @@ static int tcc_compile(TCCState *s1)
define_start = define_stack;
nocode_wanted = 1;
+ pvtop = vtop;
if (setjmp(s1->error_jmp_buf) == 0) {
s1->nb_errors = 0;
@@ -787,6 +789,8 @@ static int tcc_compile(TCCState *s1)
sym_pop(&global_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;
}