Skip to content

Commit

Permalink
[Fix](Exception) throw exception in defer may result std::terminate (… (
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon authored Aug 7, 2024
1 parent 8cb5aa6 commit 7550fba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion be/src/vec/functions/function_variant_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ class FunctionVariantElement : public IFunction {
static Status get_element_column(const ColumnObject& src, const ColumnPtr& index_column,
ColumnPtr* result) {
std::string field_name = index_column->get_data_at(0).to_string();
Defer finalize([&]() { (*result)->assume_mutable()->finalize(); });
if (src.empty()) {
*result = ColumnObject::create(true);
// src subcolumns empty but src row count may not be 0
(*result)->assume_mutable()->insert_many_defaults(src.size());
(*result)->assume_mutable()->finalize();
return Status::OK();
}
if (src.is_scalar_variant() &&
Expand All @@ -132,6 +132,7 @@ class FunctionVariantElement : public IFunction {
}
}
*result = ColumnObject::create(true, type, std::move(result_column));
(*result)->assume_mutable()->finalize();
return Status::OK();
} else {
auto mutable_src = src.clone_finalized();
Expand Down Expand Up @@ -173,6 +174,7 @@ class FunctionVariantElement : public IFunction {
result_col->insert_many_defaults(src.size());
}
*result = result_col->get_ptr();
(*result)->assume_mutable()->finalize();
VLOG_DEBUG << "dump new object "
<< static_cast<const ColumnObject*>(result_col.get())->debug_string()
<< ", path " << path.get_path();
Expand Down

0 comments on commit 7550fba

Please sign in to comment.