Skip to content

Commit

Permalink
crypto: don't call callback twice in case crypto.randomBytes fails
Browse files Browse the repository at this point in the history
PR-URL: #40157
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
  • Loading branch information
lbguilherme authored and targos committed Oct 4, 2021
1 parent 94b415b commit 7968c79
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function randomBytes(size, callback) {

// Keep the callback as a regular function so this is propagated.
randomFill(buf.buffer, 0, size, function(error) {
if (error) FunctionPrototypeCall(callback, this, error);
if (error) return FunctionPrototypeCall(callback, this, error);
FunctionPrototypeCall(callback, this, null, buf);
});
}
Expand Down

0 comments on commit 7968c79

Please sign in to comment.