cmCMakePath: support constructing `.end()` iterators

Dereferencing the iterator must be avoided once it becomes the `.end()`
value. Check for iterator validity before updating the `PathElement`
member.
1 file changed