summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-03-07 19:15:25 +0100
committerMyles Borins <mylesborins@google.com>2018-03-20 12:02:29 +0000
commit49391a70e134e7f6e353569b8b05ec6c4360fc2a (patch)
tree7f80eaed6d25a51071ec951fc5cc8f2ced960682
parent1ba1861731a40dca42967c98f85f378995672388 (diff)
downloadnode-new-49391a70e134e7f6e353569b8b05ec6c4360fc2a.tar.gz
src: fix util abort
This makes sure util.isRegExp and util.isDate will not abort in case more than one argument is passed to the function. PR-URL: https://github.com/nodejs/node/pull/19223 Reviewed-By: Myles Borins <myles.borins@gmail.com>
-rw-r--r--src/node_util.cc2
-rw-r--r--test/parallel/test-util.js5
2 files changed, 3 insertions, 4 deletions
diff --git a/src/node_util.cc b/src/node_util.cc
index 864cb0f0e0..852902d7cc 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -37,7 +37,6 @@ using v8::Value;
#define V(_, ucname) \
static void ucname(const FunctionCallbackInfo<Value>& args) { \
- CHECK_EQ(1, args.Length()); \
args.GetReturnValue().Set(args[0]->ucname()); \
}
@@ -45,7 +44,6 @@ using v8::Value;
#undef V
static void IsAnyArrayBuffer(const FunctionCallbackInfo<Value>& args) {
- CHECK_EQ(1, args.Length());
args.GetReturnValue().Set(
args[0]->IsArrayBuffer() || args[0]->IsSharedArrayBuffer());
}
diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js
index 3b2729c107..a4aec080a9 100644
--- a/test/parallel/test-util.js
+++ b/test/parallel/test-util.js
@@ -43,9 +43,10 @@ assert.strictEqual(false, util.isArray(Object.create(Array.prototype)));
// isRegExp
assert.strictEqual(true, util.isRegExp(/regexp/));
-assert.strictEqual(true, util.isRegExp(RegExp()));
+assert.strictEqual(true, util.isRegExp(RegExp(), 'foo'));
assert.strictEqual(true, util.isRegExp(new RegExp()));
assert.strictEqual(true, util.isRegExp(context('RegExp')()));
+assert.strictEqual(false, util.isRegExp());
assert.strictEqual(false, util.isRegExp({}));
assert.strictEqual(false, util.isRegExp([]));
assert.strictEqual(false, util.isRegExp(new Date()));
@@ -53,7 +54,7 @@ assert.strictEqual(false, util.isRegExp(Object.create(RegExp.prototype)));
// isDate
assert.strictEqual(true, util.isDate(new Date()));
-assert.strictEqual(true, util.isDate(new Date(0)));
+assert.strictEqual(true, util.isDate(new Date(0), 'foo'));
assert.strictEqual(true, util.isDate(new (context('Date'))()));
assert.strictEqual(false, util.isDate(Date()));
assert.strictEqual(false, util.isDate({}));