Skip to content

Commit

Permalink
fix: out of range case in gas estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
librelois committed Feb 3, 2022
1 parent 3471178 commit 3aa4b0f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> Result<()
// should contain a utf-8 encoded revert reason.
if data.len() > 68 {
let message_len = data[36..68].iter().sum::<u8>();
let body: &[u8] = &data[68..68 + message_len as usize];
if let Ok(reason) = std::str::from_utf8(body) {
message = format!("{} {}", message, reason.to_string());
if data.len() >= 68 + message_len as usize {
let body: &[u8] = &data[68..68 + message_len as usize];
if let Ok(reason) = std::str::from_utf8(body) {
message = format!("{} {}", message, reason.to_string());
}
}
}
Err(Error {
Expand Down

0 comments on commit 3aa4b0f

Please sign in to comment.