From 902527e52945fea8fa4e962cc92e4ad438cef8dd Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 11 Apr 2017 12:13:08 -0700 Subject: [PATCH] Node server: add NULL check to tryShutdown --- ext/server.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ext/server.cc b/ext/server.cc index 22c89c58..2d017dd0 100644 --- a/ext/server.cc +++ b/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(info.This()); + if (server->wrapped_server == NULL) { + // Server is already shut down. Call callback immediately. + Nan::Callback callback(info[0].As()); + callback.Call(0, {}); + return; + } TryShutdownOp *op = new TryShutdownOp(server, info.This()); unique_ptr ops(new OpVec()); ops->push_back(unique_ptr(op));