Skip to content

Commit

Permalink
Merge pull request #2225 from Crypt-iQ/statusbytes_08062024
Browse files Browse the repository at this point in the history
blockchain: copy utxo status bytes to avoid UB
  • Loading branch information
Roasbeef authored Aug 9, 2024
2 parents b161cd6 + 3eda1a5 commit 97400aa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion blockchain/chainio.go
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,14 @@ func dbPutUtxoStateConsistency(dbTx database.Tx, hash *chainhash.Hash) error {
// nothing was found.
func dbFetchUtxoStateConsistency(dbTx database.Tx) []byte {
// Fetch the serialized data from the database.
return dbTx.Metadata().Get(utxoStateConsistencyKeyName)
statusBytes := dbTx.Metadata().Get(utxoStateConsistencyKeyName)
if statusBytes != nil {
result := make([]byte, len(statusBytes))
copy(result, statusBytes)
return result
}

return nil
}

// createChainState initializes both the database and the chain state to the
Expand Down

0 comments on commit 97400aa

Please sign in to comment.