Node server: add NULL check to tryShutdown

pull/10563/head
murgatroid99 8 years ago
parent c22d62f54e
commit 803392e9f1
  1. 6
      src/node/ext/server.cc

@ -277,6 +277,12 @@ NAN_METHOD(Server::TryShutdown) {
return Nan::ThrowTypeError("tryShutdown can only be called on a Server");
}
Server *server = ObjectWrap::Unwrap<Server>(info.This());
if (server->wrapped_server == NULL) {
// Server is already shut down. Call callback immediately.
Nan::Callback callback(info[0].As<Function>());
callback.Call(0, {});
return;
}
TryShutdownOp *op = new TryShutdownOp(server, info.This());
unique_ptr<OpVec> ops(new OpVec());
ops->push_back(unique_ptr<Op>(op));

Loading…
Cancel
Save