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.
This commit is contained in:
grischka
2017-02-13 18:23:55 +01:00
parent a4a20360e9
commit 13056da039
4 changed files with 38 additions and 14 deletions

14
tccpe.c
View File

@ -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