From 83c58524655db2da394e2bedde127326afe073b0 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Wed, 23 Jun 2021 22:42:02 -0400 Subject: [PATCH] allow terrible method hack to decompiler (#623) --- decompiler/IR2/AtomicOpTypeAnalysis.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/decompiler/IR2/AtomicOpTypeAnalysis.cpp b/decompiler/IR2/AtomicOpTypeAnalysis.cpp index 4761dfa57..1b4e4cc3e 100644 --- a/decompiler/IR2/AtomicOpTypeAnalysis.cpp +++ b/decompiler/IR2/AtomicOpTypeAnalysis.cpp @@ -772,11 +772,13 @@ TP_Type LoadVarOp::get_src_type(const TypeState& input, ro.offset >= 16 && (ro.offset & 3) == 0 && m_size == 4 && m_kind == Kind::UNSIGNED) { // method get of an unknown type. We assume the most general "object" type. auto method_id = (ro.offset - 16) / 4; - auto method_info = dts.ts.lookup_method("object", method_id); - if (method_id != GOAL_NEW_METHOD && method_id != GOAL_RELOC_METHOD) { - // this can get us the wrong thing for `new` methods. And maybe relocate? - return TP_Type::make_non_virtual_method( - method_info.type.substitute_for_method_call("object"), TypeSpec("object"), method_id); + if (method_id <= (int)GOAL_MEMUSAGE_METHOD) { + auto method_info = dts.ts.lookup_method("object", method_id); + if (method_id != GOAL_NEW_METHOD && method_id != GOAL_RELOC_METHOD) { + // this can get us the wrong thing for `new` methods. And maybe relocate? + return TP_Type::make_non_virtual_method( + method_info.type.substitute_for_method_call("object"), TypeSpec("object"), method_id); + } } }