Skip to content

Commit

Permalink
fixup! crypto: add buffering to randomInt
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen committed Jan 12, 2021
1 parent 3988798 commit 2ca9712
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const {
const { validateNumber } = require('internal/validators');
const { isArrayBufferView } = require('internal/util/types');
const { FastBuffer } = require('internal/buffer');
const { setImmediate } = require('timers');

const kMaxUint32 = 2 ** 32 - 1;
const kMaxPossibleLength = MathMin(kMaxLength, kMaxUint32);
Expand Down Expand Up @@ -187,7 +186,7 @@ function randomInt(min, max, callback) {
if (x <= randLimit) {
const n = (x % range) + min;
if (isSync) return n;
setImmediate(() => callback(undefined, n));
process.nextTick(callback, undefined, n);
return;
}
}
Expand Down

0 comments on commit 2ca9712

Please sign in to comment.