[FileSystem] Fix access to destroyed stack object 81/181681/1
authorRafal Walczyna <r.walczyna@partner.samsung.com>
Fri, 15 Jun 2018 12:32:38 +0000 (14:32 +0200)
committerRafal Walczyna <r.walczyna@partner.samsung.com>
Fri, 15 Jun 2018 12:32:38 +0000 (14:32 +0200)
[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 <r.walczyna@partner.samsung.com>
src/filesystem/filesystem_instance.cc

index 733d75d33f7a700016b6b9bf72470d9f6014ee03..8efd6d2219a172f2155584308ccc4c31dc751a83 100644 (file)
@@ -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<std::mutex> lock(mutex);
-                             conditional_variable.wait(lock, [&ready] { return ready; });
-
-                             logic(out);
-                             done = true;
-                           }
+                           // wait for close
+                           std::unique_lock<std::mutex> lock(mutex);
+                           conditional_variable.wait(lock, [&ready] { return ready; });
+
+                           logic(out);
+                           done = true;
                            conditional_variable.notify_one();
                          });