From a5a0e548f2761b4b8d40097ce1504feb1bd7b74c Mon Sep 17 00:00:00 2001 From: Rafal Walczyna Date: Fri, 15 Jun 2018 14:32:38 +0200 Subject: [PATCH] [FileSystem] Fix access to destroyed stack object [Bug] Application used variable which was destroyed in different thread. [Verification] Tested in Chrome console. SATIZENVUL-1467 Change-Id: I1461e39c0d5a879ccaa8263cfef675c51e629a77 Signed-off-by: Rafal Walczyna --- src/filesystem/filesystem_instance.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/filesystem/filesystem_instance.cc b/src/filesystem/filesystem_instance.cc index 733d75d3..8efd6d22 100644 --- a/src/filesystem/filesystem_instance.cc +++ b/src/filesystem/filesystem_instance.cc @@ -2312,14 +2312,12 @@ void FilesystemInstance::FileHandleClose(const picojson::value& args, picojson:: // FILE* this->worker.add_job([] {}, [&conditional_variable, &mutex, &ready, &done, logic, &out] { - { - // wait for close - std::unique_lock lock(mutex); - conditional_variable.wait(lock, [&ready] { return ready; }); - - logic(out); - done = true; - } + // wait for close + std::unique_lock lock(mutex); + conditional_variable.wait(lock, [&ready] { return ready; }); + + logic(out); + done = true; conditional_variable.notify_one(); }); -- 2.34.1