Skip to content

Commit 49391a7

Browse files
BridgeARMylesBorins
authored andcommitted
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: #19223 Reviewed-By: Myles Borins <[email protected]>
1 parent 1ba1861 commit 49391a7

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/node_util.cc

-2
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@ using v8::Value;
3737

3838
#define V(_, ucname) \
3939
static void ucname(const FunctionCallbackInfo<Value>& args) { \
40-
CHECK_EQ(1, args.Length()); \
4140
args.GetReturnValue().Set(args[0]->ucname()); \
4241
}
4342

4443
VALUE_METHOD_MAP(V)
4544
#undef V
4645

4746
static void IsAnyArrayBuffer(const FunctionCallbackInfo<Value>& args) {
48-
CHECK_EQ(1, args.Length());
4947
args.GetReturnValue().Set(
5048
args[0]->IsArrayBuffer() || args[0]->IsSharedArrayBuffer());
5149
}

test/parallel/test-util.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ assert.strictEqual(false, util.isArray(Object.create(Array.prototype)));
4343

4444
// isRegExp
4545
assert.strictEqual(true, util.isRegExp(/regexp/));
46-
assert.strictEqual(true, util.isRegExp(RegExp()));
46+
assert.strictEqual(true, util.isRegExp(RegExp(), 'foo'));
4747
assert.strictEqual(true, util.isRegExp(new RegExp()));
4848
assert.strictEqual(true, util.isRegExp(context('RegExp')()));
49+
assert.strictEqual(false, util.isRegExp());
4950
assert.strictEqual(false, util.isRegExp({}));
5051
assert.strictEqual(false, util.isRegExp([]));
5152
assert.strictEqual(false, util.isRegExp(new Date()));
5253
assert.strictEqual(false, util.isRegExp(Object.create(RegExp.prototype)));
5354

5455
// isDate
5556
assert.strictEqual(true, util.isDate(new Date()));
56-
assert.strictEqual(true, util.isDate(new Date(0)));
57+
assert.strictEqual(true, util.isDate(new Date(0), 'foo'));
5758
assert.strictEqual(true, util.isDate(new (context('Date'))()));
5859
assert.strictEqual(false, util.isDate(Date()));
5960
assert.strictEqual(false, util.isDate({}));

0 commit comments

Comments
 (0)