Skip to content

Commit

Permalink
[Electric-Coin-Company#1420] Synchronizer.proposeShielding crashes wh…
Browse files Browse the repository at this point in the history
…en there are insufficient funds to shield

- Check for the null value of the pointer when constructing propose shielding

[Electric-Coin-Company#1420] Synchronizer.proposeShielding crashes when there are insufficient funds to shield

- throw an error instead of returning nil value
  • Loading branch information
LukasKorba committed May 14, 2024
1 parent 31a5848 commit 5373c99
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,11 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
}

defer { zcashlc_free_boxed_slice(proposal) }


guard proposal.pointee.ptr != nil else {
throw ZcashError.rustShieldFunds(lastErrorMessage(fallback: "`proposeShielding` insufficient funds to shield"))
}

return try FfiProposal(contiguousBytes: Data(
bytes: proposal.pointee.ptr,
count: Int(proposal.pointee.len)
Expand Down

0 comments on commit 5373c99

Please sign in to comment.