Skip to content

Commit

Permalink
[BugFix] Fix TableFuncitonState use after free (StarRocks#20588)
Browse files Browse the repository at this point in the history
Fix StarRocks#20587

Signed-off-by: sduzh <[email protected]>
  • Loading branch information
sduzh authored Mar 29, 2023
1 parent 2444653 commit 81050df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion be/src/exec/pipeline/table_function_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace starrocks::pipeline {
void TableFunctionOperator::close(RuntimeState* state) {
if (_table_function != nullptr && _table_function_state != nullptr) {
_table_function->close(state, _table_function_state);
_table_function_state = nullptr;
}
Operator::close(state);
}
Expand All @@ -27,7 +28,8 @@ bool TableFunctionOperator::has_output() const {
if (!_table_function_result.first.empty() && _next_output_row < _table_function_result.first[0]->size()) {
return true;
}
if (_input_chunk != nullptr && _table_function_state->processed_rows() < _input_chunk->num_rows()) {
if (_input_chunk != nullptr && _table_function_state != nullptr &&
_table_function_state->processed_rows() < _input_chunk->num_rows()) {
return true;
}
return false;
Expand Down
11 changes: 6 additions & 5 deletions be/test/exprs/array_functions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5063,7 +5063,6 @@ TEST_F(ArrayFunctionsTest, array_distinct_any_type_only_null) {
}
}


TEST_F(ArrayFunctionsTest, array_intersect_any_type_int) {
auto src_column = ColumnHelper::create_column(TYPE_ARRAY_INT, true);
src_column->append_datum(DatumArray{(int32_t)5, (int32_t)3, (int32_t)6});
Expand All @@ -5083,7 +5082,8 @@ TEST_F(ArrayFunctionsTest, array_intersect_any_type_int) {
src_column3->append_datum(DatumArray{(int32_t)(4), (int32_t)(1)});
src_column3->append_datum(DatumArray{(int32_t)(100)});

auto dest_column = ArrayFunctions::array_intersect_any_type(nullptr, {src_column, src_column2, src_column3}).value();
auto dest_column =
ArrayFunctions::array_intersect_any_type(nullptr, {src_column, src_column2, src_column3}).value();

ASSERT_EQ(dest_column->size(), 4);
_check_array<int32_t>({(int32_t)(5)}, dest_column->get(0).get_array());
Expand Down Expand Up @@ -5111,7 +5111,8 @@ TEST_F(ArrayFunctionsTest, array_intersect_any_type_int_with_not_null) {
src_column3->append_datum(DatumArray{(int32_t)(4), (int32_t)(1)});
src_column3->append_datum(DatumArray{(int32_t)(4), Datum(), (int32_t)(2), (int32_t)(22), (int32_t)(1)});

auto dest_column = ArrayFunctions::array_intersect_any_type(nullptr, {src_column, src_column2, src_column3}).value();
auto dest_column =
ArrayFunctions::array_intersect_any_type(nullptr, {src_column, src_column2, src_column3}).value();

ASSERT_EQ(dest_column->size(), 4);
_check_array<int32_t>({(int32_t)(5)}, dest_column->get(0).get_array());
Expand Down Expand Up @@ -5163,7 +5164,8 @@ TEST_F(ArrayFunctionsTest, array_intersect_any_type_varchar) {
src_column3->append_datum(DatumArray{Slice("4"), Slice("1")});
src_column3->append_datum(DatumArray{Slice("100")});

auto dest_column = ArrayFunctions::array_intersect_any_type(nullptr, {src_column, src_column2, src_column3}).value();
auto dest_column =
ArrayFunctions::array_intersect_any_type(nullptr, {src_column, src_column2, src_column3}).value();

ASSERT_EQ(dest_column->size(), 4);
_check_array<Slice>({Slice("5")}, dest_column->get(0).get_array());
Expand Down Expand Up @@ -5225,7 +5227,6 @@ TEST_F(ArrayFunctionsTest, array_intersect_any_type_varchar_with_not_null) {
}
}


TEST_F(ArrayFunctionsTest, array_reverse_any_types_int) {
auto src_column = ColumnHelper::create_column(TYPE_ARRAY_INT, true);
src_column->append_datum(DatumArray{5, 3, 6});
Expand Down

0 comments on commit 81050df

Please sign in to comment.