diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index fe76cf1a69ef43..da1ecb80c8941f 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -40,6 +40,7 @@ const { Buffer, kMaxLength } = require('buffer'); const { codes: { ERR_INVALID_ARG_TYPE, + ERR_MISSING_ARGS, ERR_OUT_OF_RANGE, ERR_OPERATION_FAILED, } @@ -315,6 +316,8 @@ function onJobDone(buf, callback, error) { // not allowed to exceed 65536 bytes, and can only // be an integer-type TypedArray. function getRandomValues(data) { + if (arguments.length < 1) + throw new ERR_MISSING_ARGS('typedArray'); if (!isTypedArray(data) || isFloat32Array(data) || isFloat64Array(data)) {