浏览代码

server-mode: Prevent possible crash when watching directories

The `filename` passed by libuv may be `nullptr`, so handle that
explicitly.

Fixes: #16422
Tobias Hunger 9 年之前
父节点
当前提交
d0a707b3d0
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Source/cmFileMonitor.cxx

+ 1 - 1
Source/cmFileMonitor.cxx

@@ -288,7 +288,7 @@ void on_directory_change(uv_fs_event_t* handle, const char* filename,
 {
 {
   const cmIBaseWatcher* const watcher =
   const cmIBaseWatcher* const watcher =
     static_cast<const cmIBaseWatcher*>(handle->data);
     static_cast<const cmIBaseWatcher*>(handle->data);
-  const std::string pathSegment(filename);
+  const std::string pathSegment(filename ? filename : "");
   watcher->Trigger(pathSegment, events, status);
   watcher->Trigger(pathSegment, events, status);
 }
 }