Skip to content

Commit

Permalink
avoid a panic in case we try decoding naff bytes (#1444)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdw authored Feb 24, 2024
1 parent 19be36c commit 70d56dc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions subxt/src/backend/legacy/rpc_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,13 @@ impl DryRunResultBytes {
// dryRun returns an ApplyExtrinsicResult, which is basically a
// `Result<Result<(), DispatchError>, TransactionValidityError>`.
let bytes = self.0;

// We expect at least 2 bytes. In case we got a naff response back (or
// manually constructed this struct), just error to avoid a panic:
if bytes.len() < 2 {
return Err(crate::Error::Unknown(bytes));
}

if bytes[0] == 0 && bytes[1] == 0 {
// Ok(Ok(())); transaction is valid and executed ok
Ok(DryRunResult::Success)
Expand Down

0 comments on commit 70d56dc

Please sign in to comment.