server-mode: Prevent possible crash when watching directories

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

Fixes: #16422
This commit is contained in:
Tobias Hunger 2016-11-14 15:38:05 +01:00 committed by Brad King
parent 5cfc2e926a
commit d0a707b3d0
1 changed files with 1 additions and 1 deletions

View File

@ -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);
} }