Prevent going beyond the index of const_columns_to_remove.

This commit is contained in:
chen768959 2023-07-20 19:03:42 +08:00
parent 067e3caa2c
commit 84f6a7336c

View File

@ -38,11 +38,12 @@ FinishSortingTransform::FinishSortingTransform(
/// Remove constants from description_sorted_. /// Remove constants from description_sorted_.
SortDescription description_sorted_without_constants; SortDescription description_sorted_without_constants;
description_sorted_without_constants.reserve(description_sorted_.size()); description_sorted_without_constants.reserve(description_sorted_.size());
size_t num_columns = const_columns_to_remove.size();
for (const auto & column_description : description_sorted_) for (const auto & column_description : description_sorted_)
{ {
auto pos = header.getPositionByName(column_description.column_name); auto pos = header.getPositionByName(column_description.column_name);
if (!const_columns_to_remove[pos]){ if (pos < num_columns && !const_columns_to_remove[pos]){
description_sorted_without_constants.push_back(column_description); description_sorted_without_constants.push_back(column_description);
} }
} }