Skip to content

Commit

Permalink
🔧 fix: panic when inferring storage mapping types
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Becker committed May 22, 2023
1 parent 37b87fa commit 40fdb11
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions heimdall/src/decompile/out/postprocessers/solidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down

0 comments on commit 40fdb11

Please sign in to comment.