aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormingodad <mingodad@gmail.com>2014-03-25 18:06:14 +0000
committermingodad <mingodad@gmail.com>2014-03-25 18:06:14 +0000
commitad9568060eefbf79073f260249fe1ff8df59bf53 (patch)
treee58b15e8c46db6a898891227af0b4cc79dc01210
parentdc8ea93b13faefb565fb937f8b8c08c40c063549 (diff)
downloadtinycc-ad9568060eefbf79073f260249fe1ff8df59bf53.tar.gz
tinycc-ad9568060eefbf79073f260249fe1ff8df59bf53.tar.bz2
A possible fix for the memory leak reported by valgrind when running tcctest.c with tcc.
-rw-r--r--libtcc.c2
-rw-r--r--tccelf.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/libtcc.c b/libtcc.c
index dc78643..601999e 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1094,6 +1094,8 @@ LIBTCCAPI void tcc_delete(TCCState *s1)
# endif
#endif
+ if(s1->sym_attrs) tcc_free(s1->sym_attrs);
+
tcc_free(s1);
}
diff --git a/tccelf.c b/tccelf.c
index 036dba3..6bde7d5 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -2444,6 +2444,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
tcc_free(sec_order);
tcc_free(phdr);
tcc_free(s1->sym_attrs);
+ s1->sym_attrs = NULL;
return ret;
}