`dynamic_cast` on pointers may return `nullptr`, then accessing line's length cause an exception. Would be better to check beforehand.