Fix crash issue related to delete this 64/309164/3
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 5 Apr 2024 08:22:39 +0000 (17:22 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 5 Apr 2024 08:48:57 +0000 (17:48 +0900)
While calling OnFileCreated(), we should not release the FileMonitor
instance. If it's deleted, it causes the crash issue.

Change-Id: I203db1fec079f705d3f6008944f0c8f3848cb04d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/file-monitor-internal.cc
src/proxy-internal.cc

index ad41da58706779f630ae562903f6a0d3456daf47..f8b03035b3e8786c4491d36c20a33496b23bff32 100644 (file)
@@ -126,9 +126,12 @@ gboolean FileMonitor::GIOFunc(GIOChannel* channel, GIOCondition condition,
 
       if (monitor->file_name_ != event->name) continue;
 
-      if (event->mask & IN_CREATE)
+      if (event->mask & IN_CREATE) {
         listener->OnFileCreated(monitor->path_);
-      else if (event->mask & IN_DELETE)
+        return G_SOURCE_CONTINUE;
+      }
+
+      if (event->mask & IN_DELETE)
         listener->OnFileDeleted(monitor->path_);
     }
   }
index 458a43ca622407f96bd516701abed826ac7edad7..64ec93f9b1fda2f89fd04fca122d11619759c988 100644 (file)
@@ -354,7 +354,9 @@ int Proxy::Watch() {
 
 void Proxy::Cancel() {
   std::lock_guard<std::recursive_mutex> lock(GetMutex());
-  file_monitor_.reset();
+  if (!file_monitor_) return;
+
+  file_monitor_->Stop();
 }
 
 void Proxy::SetRealAppId(const std::string& alias_appid) {