From d2830db94d812ff2dbfd8b36d3df8afc433e1f13 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 20 Sep 2016 20:43:48 -0700 Subject: [PATCH] Fix memory leak modified: p_lx_elf.cpp --- src/p_lx_elf.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index afb74677..357fc445 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -230,16 +230,14 @@ PackLinuxElf32::PackLinuxElf32help1(InputFile *f) if (f && Elf32_Ehdr::ET_DYN!=e_type) { unsigned const len = sz_phdrs + e_phoff; - assert(file_image == NULL); - file_image = New(char, len); + assert(file_image != NULL); // set by PackLinuxElf64help1 f->seek(0, SEEK_SET); f->readx(file_image, len); phdri= (Elf32_Phdr *)(e_phoff + file_image); // do not free() !! } if (f && Elf32_Ehdr::ET_DYN==e_type) { // The DT_STRTAB has no designated length. Read the whole file. - assert(file_image == NULL); - file_image = New(char, file_size); + assert(file_image != NULL); // set by PackLinuxElf64help1 f->seek(0, SEEK_SET); f->readx(file_image, file_size); phdri= (Elf32_Phdr *)(e_phoff + file_image); // do not free() !! @@ -602,16 +600,14 @@ PackLinuxElf64::PackLinuxElf64help1(InputFile *f) if (f && Elf64_Ehdr::ET_DYN!=e_type) { unsigned const len = sz_phdrs + e_phoff; - assert(file_image == NULL); - file_image = New(char, len); + assert(file_image != NULL); // set by PackLinuxElf64help1 f->seek(0, SEEK_SET); f->readx(file_image, len); phdri= (Elf64_Phdr *)(e_phoff + file_image); // do not free() !! } if (f && Elf64_Ehdr::ET_DYN==e_type) { // The DT_STRTAB has no designated length. Read the whole file. - assert(file_image == NULL); - file_image = New(char, file_size); + assert(file_image != NULL); // set by PackLinuxElf64help1 f->seek(0, SEEK_SET); f->readx(file_image, file_size); phdri= (Elf64_Phdr *)(e_phoff + file_image); // do not free() !! @@ -1666,8 +1662,7 @@ PackLinuxElf64ppcle::canPack() if (Elf32_Ehdr::ET_DYN==get_te16(&ehdr->e_type)) { // The DT_STRTAB has no designated length. Read the whole file. - assert(file_image == NULL); - file_image = New(char, file_size); + assert(file_image != NULL); // set by PackLinuxElf64help1 fi->seek(0, SEEK_SET); fi->readx(file_image, file_size); memcpy(&ehdri, ehdr, sizeof(Elf64_Ehdr)); @@ -1842,8 +1837,7 @@ PackLinuxElf64amd::canPack() if (Elf32_Ehdr::ET_DYN==get_te16(&ehdr->e_type)) { // The DT_STRTAB has no designated length. Read the whole file. - assert(file_image == NULL); - file_image = New(char, file_size); + assert(file_image != NULL); // set by PackLinuxElf64help1 fi->seek(0, SEEK_SET); fi->readx(file_image, file_size); memcpy(&ehdri, ehdr, sizeof(Elf64_Ehdr));