diff --git a/Packager/Packager.cpp b/Packager/Packager.cpp index 0eb713a1b2..690c1d09f6 100644 --- a/Packager/Packager.cpp +++ b/Packager/Packager.cpp @@ -73,23 +73,25 @@ namespace { { ASSERT(_service == service); - _service->Unregister(&_notification); - - if (_implementation->Release() != Core::ERROR_DESTRUCTION_SUCCEEDED) { - - ASSERT(_connectionId != 0); + if (_service != nullptr) { + _service->Unregister(&_notification); +} - RPC::IRemoteConnection* connection(_service->RemoteConnection(_connectionId)); + if (_implementation != nullptr) { + if (_implementation->Release() != Core::ERROR_DESTRUCTION_SUCCEEDED) { + ASSERT(_connectionId != 0); - // The process can disappear in the meantime... - if (connection != nullptr) { + RPC::IRemoteConnection* connection(_service->RemoteConnection(_connectionId)); - // But if it did not dissapear in the meantime, forcefully terminate it. Shoot to kill :-) - connection->Terminate(); - connection->Release(); - } - } + // The process can disappear in the meantime... + if (connection != nullptr) { + // But if it did not dissapear in the meantime, forcefully terminate it. Shoot to kill :-) + connection->Terminate(); + connection->Release(); + } + } + } _service = nullptr; _implementation = nullptr; }