Check for null path components before attempting to setPath