to issue<51872346>:fix core when access uninit memory

This commit is contained in:
hanr881
2023-08-30 02:44:09 +00:00
committed by ob-robot
parent e98e93e8e0
commit b2520806ee

View File

@ -88,11 +88,8 @@ int ObExprSet::eval_coll(const ObObj &obj, ObExecContext &ctx, pl::ObPLNestedTab
ObIAllocator *collection_allocator = NULL;
ObObj *data_arr = NULL;
int64_t elem_count = 0;
coll = static_cast<pl::ObPLNestedTable*>(allocator.alloc(sizeof(pl::ObPLNestedTable)));
if (OB_ISNULL(coll)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc memory failed.", K(ret));
} else if (OB_ISNULL(c1)) {
if (OB_ISNULL(c1)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("union udt failed due to null udt", K(ret), K(obj));
} else if (pl::PL_NESTED_TABLE_TYPE != c1->get_type()) {
@ -102,6 +99,11 @@ int ObExprSet::eval_coll(const ObObj &obj, ObExecContext &ctx, pl::ObPLNestedTab
} else if (0 > c1->get_count() || !(c1->is_inited())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("union udt failed due to null udt", K(ret), K(c1->get_count()), K(c1->is_inited()));
} else {
coll = static_cast<pl::ObPLNestedTable*>(allocator.alloc(sizeof(pl::ObPLNestedTable)));
if (OB_ISNULL(coll)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc memory failed.", K(ret));
} else {
coll = new(coll)pl::ObPLNestedTable(c1->get_id());
collection_allocator =
@ -120,6 +122,7 @@ int ObExprSet::eval_coll(const ObObj &obj, ObExecContext &ctx, pl::ObPLNestedTab
}
}
}
}
if (OB_FAIL(ret)) {
LOG_WARN("failed to calc set operator", K(ret), K(data_arr));
}
@ -175,8 +178,10 @@ int ObExprSet::calc_set(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum)
OX (obj->set_extend(reinterpret_cast<int64_t>(coll), coll->get_type()));
OZ (expr_datum.from_obj(*obj));
//Collection constructed here must be recorded and destructed at last
if (OB_NOT_NULL(coll->get_allocator()) &&
OB_NOT_NULL(dynamic_cast<pl::ObPLCollAllocator*>(coll->get_allocator()))) {
if (OB_NOT_NULL(coll) &&
OB_NOT_NULL(coll->get_allocator())) {
common::ObIAllocator *collection_allocator = dynamic_cast<pl::ObPLCollAllocator*>(coll->get_allocator());
if (OB_NOT_NULL(collection_allocator)) {
int tmp_ret = OB_SUCCESS;
auto &exec_ctx = ctx.exec_ctx_;
if (OB_ISNULL(exec_ctx.get_pl_ctx())) {
@ -191,6 +196,7 @@ int ObExprSet::calc_set(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum)
ret = OB_SUCCESS == ret ? tmp_ret : ret;
}
}
}
#endif
return ret;
}