Skip to content

Commit 34769a1

Browse files
committed
src: add args validation method
1 parent b0c65bb commit 34769a1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/tcp_wrap.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@ void TCPWrap::Listen(const FunctionCallbackInfo<Value>& args) {
291291

292292

293293
void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
294+
if (args.Length() <= 2) {
295+
// Throw an exception for insufficient arguments
296+
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
297+
v8::String::NewFromUtf8(args.GetIsolate(), "Insufficient arguments").ToLocalChecked()));
298+
return;
299+
}
300+
294301
CHECK(args[2]->IsUint32());
295302
// explicit cast to fit to libuv's type expectation
296303
int port = static_cast<int>(args[2].As<Uint32>()->Value());

0 commit comments

Comments
 (0)