From 94fa2cccbacbcbbedb332cd5409dc58998b9406d Mon Sep 17 00:00:00 2001 From: Tyler Smith Date: Fri, 16 Aug 2024 22:17:03 -0400 Subject: [PATCH] fix: Propagate error from rand.Read, which can fail in some rare cases. --- bip39.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bip39.go b/bip39.go index 2ef9833..dc49b73 100644 --- a/bip39.go +++ b/bip39.go @@ -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 }