From 35deab23499681f76d5cda73fd288131c26155b5 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 7 Mar 2018 19:15:25 +0100 Subject: [PATCH] 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. --- src/node_util.cc | 2 -- test/parallel/test-util.js | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/node_util.cc b/src/node_util.cc index 864cb0f0e0b1b0..852902d7cc8132 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& 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& 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 3b2729c107b4b1..a4aec080a9a0ad 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({}));