From d0a707b3d0c247d6bbf63fdfefc79d5ce0aea717 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 14 Nov 2016 15:38:05 +0100 Subject: [PATCH] server-mode: Prevent possible crash when watching directories The `filename` passed by libuv may be `nullptr`, so handle that explicitly. Fixes: #16422 --- Source/cmFileMonitor.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index 41ec8b415..ea37683bb 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -288,7 +288,7 @@ void on_directory_change(uv_fs_event_t* handle, const char* filename, { const cmIBaseWatcher* const watcher = static_cast(handle->data); - const std::string pathSegment(filename); + const std::string pathSegment(filename ? filename : ""); watcher->Trigger(pathSegment, events, status); }