Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Feb 20, 2024
1 parent ebfdb8f commit c438143
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Socket extends EventEmitter {
const newBuffer = buffer.slice (0, bytes);
this.emit ("message", newBuffer, source, buffer);
if(this.recvPaused) {
return undefined
return
}
buffer = this.buffer
return buffer
Expand Down
9 changes: 3 additions & 6 deletions src/raw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ NAN_METHOD(SocketWrap::Recv) {
}

if (info.Length () < 2) {
Nan::ThrowError("Five arguments are required");
Nan::ThrowError("Two arguments are required");
return;
}

Expand Down Expand Up @@ -741,13 +741,10 @@ NAN_METHOD(SocketWrap::Recv) {
argv[0] = Nan::New<Number>(rc);
argv[1] = Nan::New(addr).ToLocalChecked();
MaybeLocal<v8::Value> newBuffer = cb->Call (context, socket->handle(), 2, argv);
if(!newBuffer.ToLocal(&argv[0])) {
break;
}
MaybeLocal<Object> maybeBuffer = Nan::To<Object>(argv[0]);
if(!maybeBuffer.ToLocal(&buffer)) {
if(!newBuffer.ToLocal(&argv[0]) || !argv[0]->IsObject() || !node::Buffer::HasInstance(argv[0])) {
break;
}
buffer = argv[0]->ToObject(context).ToLocalChecked();
} while(true);

info.GetReturnValue().Set(info.This());
Expand Down

0 comments on commit c438143

Please sign in to comment.