Skip to content

Commit

Permalink
Fix MakeMaskArray iterating over the end of vector
Browse files Browse the repository at this point in the history
  • Loading branch information
amol- committed Oct 17, 2024
1 parent 33264a1 commit a07ad19
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cpp/src/arrow/array/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -921,9 +921,13 @@ Result<std::shared_ptr<Array>> MakeMaskArray(const std::vector<int64_t>& indices
BooleanBuilder builder(pool);
RETURN_NOT_OK(builder.Resize(length));

auto indices_end = indices.end();
auto i = indices.begin();
for (int64_t builder_i = 0; builder_i < length; builder_i++) {
if (builder_i == *i) {
if (i == indices_end) {
RETURN_NOT_OK(builder.AppendValues(static_cast<int64_t>(length - builder.length()), false));
break;
} else if (builder_i == *i) {
builder.UnsafeAppend(true);
i++;
} else {
Expand Down

0 comments on commit a07ad19

Please sign in to comment.