From 71620bcc6e7b9b74f473f08dcdaaa604409c9504 Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Sat, 9 Apr 2022 23:27:59 -0700 Subject: [PATCH] fixed a bug where there are symbols with section_index that are invalid... --- src/tests/demo/main.cpp | 2 +- src/theo/decomp/decomp.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tests/demo/main.cpp b/src/tests/demo/main.cpp index 43c47ab..66f13a8 100644 --- a/src/tests/demo/main.cpp +++ b/src/tests/demo/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) { return result; }; - theo::theo_t t(fdata, {allocator, copier, resolver}, "EntryPoint"); + theo::theo_t t(fdata, {allocator, copier, resolver}, "main"); auto res = t.decompose(); if (!res.has_value()) { diff --git a/src/theo/decomp/decomp.cpp b/src/theo/decomp/decomp.cpp index 5bb401c..2f1a479 100644 --- a/src/theo/decomp/decomp.cpp +++ b/src/theo/decomp/decomp.cpp @@ -25,8 +25,11 @@ std::optional decomp_t::decompose( std::for_each( m_objs.begin(), m_objs.end(), [&](std::vector& img_data) { auto img = reinterpret_cast(img_data.data()); - for (auto idx = 0u; idx < img->file_header.num_symbols - 1; ++idx) { + for (auto idx = 0u; idx < img->file_header.num_symbols; ++idx) { auto sym = img->get_symbol(idx); + if (sym->section_index - 1 > img->file_header.num_sections) + continue; + auto sym_name = symbol_t::name(img, sym); if (sym_name.length()) { auto sym_hash = symbol_t::hash(sym_name.data());