Skip to content

Commit

Permalink
[Fix](Array) correct the offset when using get_data_at from _item_con…
Browse files Browse the repository at this point in the history
…vertor (#11094)

get_data_at should use offset - offsets[start_index] since
start_index may be changed after OlapColumnDataConvertorArray::set_source_column.
Using just offset may access the memory out of _item_convertor's data range,
  • Loading branch information
eldenmoon authored Jul 22, 2022
1 parent 4003489 commit 9d21b21
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion be/src/vec/olap/olap_data_convertor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ const void* OlapBlockDataConvertor::OlapColumnDataConvertorVarChar::get_data() c

const void* OlapBlockDataConvertor::OlapColumnDataConvertorVarChar::get_data_at(
size_t offset) const {
assert(offset < _slice.size());
UInt8 null_flag = 0;
if (_nullmap) {
null_flag = _nullmap[offset];
Expand Down Expand Up @@ -729,7 +730,11 @@ Status OlapBlockDataConvertor::OlapColumnDataConvertorArray::convert_to_olap(
collection_value->set_null_signs(
const_cast<bool*>(reinterpret_cast<const bool*>(item_null_map + offset)));
}
collection_value->set_data(const_cast<void*>(_item_convertor->get_data_at(offset)));
// get_data_at should use offset - offsets[start_index] since
// start_index may be changed after OlapColumnDataConvertorArray::set_source_column.
// Using just offset may access the memory out of _item_convertor's data range,
collection_value->set_data(
const_cast<void*>(_item_convertor->get_data_at(offset - offsets[start_index])));
}
return Status::OK();
}
Expand Down

0 comments on commit 9d21b21

Please sign in to comment.