From 13056da039240a1d418335f6e0506a89fb2d8495 Mon Sep 17 00:00:00 2001 From: grischka Date: Mon, 13 Feb 2017 18:23:55 +0100 Subject: mems & leaks - define_start: set above preprocess_start because now preprocess_start is defining macros. - free "cmd_include_files" - free defines always (after error-longjmps) - close all files (after error-longjmps) - tccpe.c: free imports always - libtcc.c: call tcc_memstats only after all states have been deleted. --- tccpe.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tccpe.c') diff --git a/tccpe.c b/tccpe.c index f2dee39..8d29070 100644 --- a/tccpe.c +++ b/tccpe.c @@ -770,6 +770,16 @@ found_dll: return s; } +void pe_free_imports(struct pe_info *pe) +{ + int i; + for (i = 0; i < pe->imp_count; ++i) { + struct pe_import_info *p = pe->imp_info[i]; + dynarray_reset(&p->symbols, &p->sym_count); + } + dynarray_reset(&pe->imp_info, &pe->imp_count); +} + /*----------------------------------------------------------------------------*/ static void pe_build_imports(struct pe_info *pe) { @@ -861,9 +871,7 @@ static void pe_build_imports(struct pe_info *pe) ent_ptr += sizeof (ADDR3264); } dll_ptr += sizeof(IMAGE_IMPORT_DESCRIPTOR); - dynarray_reset(&p->symbols, &p->sym_count); } - dynarray_reset(&pe->imp_info, &pe->imp_count); } /* ------------------------------------------------------------- */ @@ -1897,6 +1905,8 @@ ST_FUNC int pe_output_file(TCCState *s1, const char *filename) #endif } + pe_free_imports(&pe); + #ifdef PE_PRINT_SECTIONS pe_print_sections(s1, "tcc.log"); #endif -- cgit v1.3.1