Skip to content

Commit 7968c79

Browse files
lbguilhermetargos
authored andcommitted
crypto: don't call callback twice in case crypto.randomBytes fails
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]>
1 parent 94b415b commit 7968c79

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/crypto/random.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function randomBytes(size, callback) {
102102

103103
// Keep the callback as a regular function so this is propagated.
104104
randomFill(buf.buffer, 0, size, function(error) {
105-
if (error) FunctionPrototypeCall(callback, this, error);
105+
if (error) return FunctionPrototypeCall(callback, this, error);
106106
FunctionPrototypeCall(callback, this, null, buf);
107107
});
108108
}

0 commit comments

Comments
 (0)