PathMonitor: check for NULL before dereferencing.

* should fix #10277.