From 362a3fde10a3bb2738fcf30ae2e2eaf4a53df042 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 31 Oct 2023 15:38:31 +0100 Subject: [ELFLOADER] Changed how memory is managed in elfloader --- src/main.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index eb185c66..0d0a61cf 100644 --- a/src/main.c +++ b/src/main.c @@ -1728,32 +1728,21 @@ int main(int argc, const char **argv, char **env) { if(CalcLoadAddr(elf_header)) { printf_log(LOG_NONE, "Error: reading elf header of %s\n", my_context->fullpath); - fclose(f); - free_contextargv(); - FreeBox64Context(&my_context); - FreeCollection(&ld_preload); - return -1; - } - // allocate memory - if(AllocElfMemory(my_context, elf_header, 1)) { - printf_log(LOG_NONE, "Error: allocating memory for elf %s\n", my_context->fullpath); - fclose(f); + FreeElfHeader(&elf_header); free_contextargv(); FreeBox64Context(&my_context); FreeCollection(&ld_preload); return -1; } - // Load elf into memory - if(LoadElfMemory(f, my_context, elf_header)) { - printf_log(LOG_NONE, "Error: loading in memory elf %s\n", my_context->fullpath); - fclose(f); + // allocate memory and load elf + if(AllocLoadElfMemory(my_context, elf_header, 1)) { + printf_log(LOG_NONE, "Error: loading elf %s\n", my_context->fullpath); + FreeElfHeader(&elf_header); free_contextargv(); FreeBox64Context(&my_context); FreeCollection(&ld_preload); return -1; } - // can close the file now - fclose(f); if(ElfCheckIfUseTCMallocMinimal(elf_header)) { if(!box64_tcmalloc_minimal) { // need to reload with tcmalloc_minimal as a LD_PRELOAD! -- cgit 1.4.1