Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid invalid access into random region in memory in OperatorUtils #12253

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion velox/exec/OperatorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,12 @@ vector_size_t processEncodedFilterResults(
auto* rawSelectedBits = filterEvalCtx.getRawSelectedBits(size, pool);
memset(rawSelectedBits, 0, bits::nbytes(size));
for (int32_t i = 0; i < size; ++i) {
if (!rows.isValid(i)) {
continue;
}
auto index = indices[i];
if ((!nulls || !bits::isBitNull(nulls, i)) &&
bits::isBitSet(values, index) && rows.isValid(i)) {
bits::isBitSet(values, index)) {
rawSelected[passed++] = i;
bits::setBit(rawSelectedBits, i);
}
Expand Down
12 changes: 12 additions & 0 deletions velox/exec/tests/OperatorUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ class OperatorUtilsTest : public OperatorTestBase {
std::unique_ptr<DriverCtx> driverCtx_;
};

TEST_F(OperatorUtilsTest, processFilterResults) {
auto filteredResults = makeArrayVector<int64_t>({{1}});
SelectivityVector filterRows(1);
filterRows.setValid(0, false);
filterRows.updateBounds();
exec::FilterEvalCtx filterEvalCtx;
EXPECT_EQ(
exec::processFilterResults(
filteredResults, filterRows, filterEvalCtx, pool_.get()),
0);
}

TEST_F(OperatorUtilsTest, wrapChildConstant) {
auto constant = makeConstant(11, 1'000);

Expand Down
Loading