The while loop in this function assumes that `data.end() - 1` is less than `data.end()`, which isn't the case if `data` is empty since `data.end()` can be a nullptr.