diff --git a/Kernel/exec/elf/parse/elf_get_dynamic_tag.cpp b/Kernel/exec/elf/parse/elf_get_dynamic_tag.cpp index c463bcf3..dd07f398 100644 --- a/Kernel/exec/elf/parse/elf_get_dynamic_tag.cpp +++ b/Kernel/exec/elf/parse/elf_get_dynamic_tag.cpp @@ -26,7 +26,7 @@ namespace Execute std::vector ret; std::vector phdrs = ELFGetSymbolType(fd, PT_DYNAMIC); - if (phdrs.size() < 1) + if (phdrs.empty()) { debug("No dynamic phdrs found."); return ret; @@ -34,7 +34,7 @@ namespace Execute for (auto phdr : phdrs) { - Elf_Dyn dyn{}; + Elf_Dyn dyn; for (size_t i = 0; i < phdr.p_filesz / sizeof(Elf_Dyn); i++) { fd->Read(&dyn, sizeof(Elf_Dyn), phdr.p_offset + (i * sizeof(Elf_Dyn))); diff --git a/Kernel/exec/elf/parse/elf_get_sections.cpp b/Kernel/exec/elf/parse/elf_get_sections.cpp index 8cf1d51a..363028c2 100644 --- a/Kernel/exec/elf/parse/elf_get_sections.cpp +++ b/Kernel/exec/elf/parse/elf_get_sections.cpp @@ -25,24 +25,22 @@ namespace Execute { std::vector ret; - Elf_Ehdr ehdr{}; + Elf_Ehdr ehdr; fd->Read(&ehdr, sizeof(Elf_Ehdr), 0); - Elf_Shdr *sections = new Elf_Shdr[ehdr.e_shnum]; - fd->Read(sections, sizeof(Elf_Shdr) * ehdr.e_shnum, ehdr.e_shoff); + std::unique_ptr sections(new Elf_Shdr[ehdr.e_shnum]); + fd->Read(sections.get(), sizeof(Elf_Shdr) * ehdr.e_shnum, ehdr.e_shoff); - char *sectionNames = new char[sections[ehdr.e_shstrndx].sh_size]; - fd->Read(sectionNames, sections[ehdr.e_shstrndx].sh_size, sections[ehdr.e_shstrndx].sh_offset); + std::string sectionNames(sections[ehdr.e_shstrndx].sh_size, '\0'); + fd->Read(sectionNames.data(), sections[ehdr.e_shstrndx].sh_size, sections[ehdr.e_shstrndx].sh_offset); for (Elf_Half i = 0; i < ehdr.e_shnum; ++i) { - const char *Name = sectionNames + sections[i].sh_name; + const char *Name = sectionNames.data() + sections[i].sh_name; if (strcmp(Name, SectionName) == 0) ret.push_back(sections[i]); } - delete[] sections; - delete[] sectionNames; return ret; } } diff --git a/Kernel/exec/elf/parse/elf_get_symbol_type.cpp b/Kernel/exec/elf/parse/elf_get_symbol_type.cpp index e90c94b8..5e22d84a 100644 --- a/Kernel/exec/elf/parse/elf_get_symbol_type.cpp +++ b/Kernel/exec/elf/parse/elf_get_symbol_type.cpp @@ -25,10 +25,10 @@ namespace Execute { std::vector ret; - Elf_Ehdr ehdr{}; + Elf_Ehdr ehdr; fd->Read(&ehdr, sizeof(Elf_Ehdr), 0); - Elf_Phdr phdr{}; + Elf_Phdr phdr; fd->Read(&phdr, sizeof(Elf_Phdr), ehdr.e_phoff); off_t off = ehdr.e_phoff;