Skip to content

Commit

Permalink
fix(response): ensure null or client/server response is returned
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Jul 8, 2018
1 parent b365934 commit 083518f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/kerberos_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ class ClientStepWorker : public Nan::AsyncWorker {
private:
virtual void HandleOKCallback() {
Nan::HandleScope scope;
v8::Local<v8::Value> argv[] = {
Nan::Null(),
Nan::New(_client->_state->response).ToLocalChecked()
};
v8::Local<v8::Value> response = Nan::Null();
if (_client->_state->response != NULL) {
response = Nan::New(_client->_state->response).ToLocalChecked();
}

v8::Local<v8::Value> argv[] = { Nan::Null(), response };
callback->Call(2, argv, async_resource);
}

Expand Down
9 changes: 5 additions & 4 deletions src/kerberos_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ class ServerStepWorker : public Nan::AsyncWorker {
private:
virtual void HandleOKCallback() {
Nan::HandleScope scope;
v8::Local<v8::Value> argv[] = {
Nan::Null(),
Nan::New(_server->_state->response).ToLocalChecked()
};
v8::Local<v8::Value> response = Nan::Null();
if (_server->_state->response != NULL) {
response = Nan::New(_server->_state->response).ToLocalChecked();
}

v8::Local<v8::Value> argv[] = { Nan::Null(), response };
callback->Call(2, argv, async_resource);
}

Expand Down

0 comments on commit 083518f

Please sign in to comment.