Skip to content

Commit 5e45b7a

Browse files
Add safety check for empty remainingOutputs in mint loop
Prevent potential crash if remainingOutputs becomes empty while remainingMintValue is still > 0. This could happen in edge cases and would cause dereferencing of an invalid iterator. Co-authored-by: reuben <[email protected]>
1 parent bf1b977 commit 5e45b7a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/spark/sparkwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ bool CSparkWallet::CreateSparkMintTransactions(
903903
singleTxOutputs.push_back(mintedCoinData);
904904
} else {
905905
uint64_t remainingMintValue = mintedValue;
906-
while (remainingMintValue > 0){
906+
while (remainingMintValue > 0 && !remainingOutputs.empty()) {
907907
// Create the mint data and push into vector
908908
uint64_t singleMintValue = std::min(remainingMintValue, remainingOutputs.begin()->v);
909909
spark::MintedCoinData mintedCoinData;

0 commit comments

Comments
 (0)