Skip to content

Commit

Permalink
src: add args validation method
Browse files Browse the repository at this point in the history
  • Loading branch information
ardinugrxha committed Jan 6, 2025
1 parent b0c65bb commit 34769a1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tcp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ void TCPWrap::Listen(const FunctionCallbackInfo<Value>& args) {


void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
if (args.Length() <= 2) {
// Throw an exception for insufficient arguments
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
v8::String::NewFromUtf8(args.GetIsolate(), "Insufficient arguments").ToLocalChecked()));
return;
}

CHECK(args[2]->IsUint32());
// explicit cast to fit to libuv's type expectation
int port = static_cast<int>(args[2].As<Uint32>()->Value());
Expand Down

0 comments on commit 34769a1

Please sign in to comment.