From 40fdb11025a2436dc14702a6e7afd9d0459becbf Mon Sep 17 00:00:00 2001 From: Jonathan Becker <64037729+Jon-Becker@users.noreply.github.com> Date: Mon, 22 May 2023 14:09:40 -0400 Subject: [PATCH] :wrench: fix: panic when inferring storage mapping types --- .../decompile/out/postprocessers/solidity.rs | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/heimdall/src/decompile/out/postprocessers/solidity.rs b/heimdall/src/decompile/out/postprocessers/solidity.rs index 508542a6..d4e973b0 100644 --- a/heimdall/src/decompile/out/postprocessers/solidity.rs +++ b/heimdall/src/decompile/out/postprocessers/solidity.rs @@ -641,21 +641,23 @@ fn inherit_infer_storage_type(line: String) { // replace the storage slot in rhs with a placeholder // this will prevent us from pulling bad types from the rhs - let rhs: String = instantiation[1].replace(&storage_slot, "_"); - - // find vars in lhs or rhs - for (var, var_type) in type_map.clone().iter() { - // check for vars in lhs - if storage_slot.contains(var) && !var_type.is_empty() { - lhs_type = var_type.to_string(); - - // continue, so we cannot use this var in rhs - continue; - } - - // check for vars in rhs - if rhs.contains(var) && !var_type.is_empty() { - rhs_type = var_type.to_string(); + if instantiation.len() > 2 { + let rhs: String = instantiation[1].replace(&storage_slot, "_"); + + // find vars in lhs or rhs + for (var, var_type) in type_map.clone().iter() { + // check for vars in lhs + if storage_slot.contains(var) && !var_type.is_empty() { + lhs_type = var_type.to_string(); + + // continue, so we cannot use this var in rhs + continue; + } + + // check for vars in rhs + if rhs.contains(var) && !var_type.is_empty() { + rhs_type = var_type.to_string(); + } } }