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

[bug](branch-2.0) Fix heap-use-after-free in the bitmap functions #27521

Merged
Merged
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
3 changes: 2 additions & 1 deletion be/src/util/bitmap_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ class BitmapValue {

// Return how many bytes are required to serialize this bitmap.
// See BitmapTypeCode for the serialized format.
size_t getSizeInBytes() const {
size_t getSizeInBytes() {
size_t res = 0;
switch (_type) {
case EMPTY:
Expand All @@ -2186,6 +2186,7 @@ class BitmapValue {
}
break;
case BITMAP:
_prepare_bitmap_for_write();
_bitmap->runOptimize();
_bitmap->shrinkToFit();
res = _bitmap->getSizeInBytes(config::bitmap_serialize_version);
Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/data_types/data_type_bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void DataTypeBitMap::to_string(const IColumn& column, size_t row_num, BufferWrit
ColumnPtr ptr = result.first;
row_num = result.second;

const auto& data = assert_cast<const ColumnBitmap&>(*ptr).get_element(row_num);
auto& data =
const_cast<BitmapValue&>(assert_cast<const ColumnBitmap&>(*ptr).get_element(row_num));
std::string buffer(data.getSizeInBytes(), '0');
data.write_to(const_cast<char*>(buffer.data()));
ostr.write(buffer.c_str(), buffer.size());
Expand Down
Loading