Skip to content

Commit

Permalink
fix: Propagate error from rand.Read, which can fail in some rare cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-smith committed Aug 17, 2024
1 parent 3423700 commit 94fa2cc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bip39.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ func NewEntropy(bitSize int) ([]byte, error) {
}

entropy := make([]byte, bitSize/8)
_, _ = rand.Read(entropy) // err is always nil
_, err := rand.Read(entropy)
if err != nil {
return nil, err
}

return entropy, nil
}
Expand Down

0 comments on commit 94fa2cc

Please sign in to comment.