diff --git a/client/rpc/src/lib.rs b/client/rpc/src/lib.rs index e9b956788d..0d07f033c5 100644 --- a/client/rpc/src/lib.rs +++ b/client/rpc/src/lib.rs @@ -221,9 +221,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::(); - 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 {