From 54d5138537135c4dbf7f8b76b0de40e8be4e330e Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Tue, 19 Jan 2016 19:38:13 -0500 Subject: [PATCH] loolwsd: proper destruction of LibreOfficeKit instance Change-Id: If39b0d534eb93044383766a51f26faac398c834e Reviewed-on: https://gerrit.libreoffice.org/21673 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian --- loolwsd/LOOLKit.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index a010383e2..0883b481d 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -784,9 +784,8 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s ("/" + loSubPath + "/program"); #endif - std::unique_ptr loKit(lok_init_2(instdir_path.c_str(), "file:///user")); - - if (!loKit) + LibreOfficeKit* loKit(lok_init_2(instdir_path.c_str(), "file:///user")); + if (loKit == nullptr) { Log::error("Error: LibreOfficeKit initialization failed. Exiting."); exit(-1); @@ -890,7 +889,7 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s Log::debug("Thread request for session [" + sessionId + "], url: [" + url + "]."); auto it = _documents.lower_bound(url); if (it == _documents.end()) - it = _documents.emplace_hint(it, url, std::make_shared(loKit.get(), jailId, url)); + it = _documents.emplace_hint(it, url, std::make_shared(loKit, jailId, url)); it->second->createSession(sessionId, intSessionId); aResponse += "ok \r\n"; @@ -925,11 +924,12 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s TerminationState = LOOLState::LOOL_ABNORMAL; } + Log::debug("Destroying documents."); _documents.clear(); // Destroy LibreOfficeKit - loKit->pClass->destroy(loKit.get()); - loKit.release(); + Log::debug("Destroying LibreOfficeKit."); + loKit->pClass->destroy(loKit); Log::info("Process [" + process_name + "] finished."); }