fix context core because of double free

This commit is contained in:
18523270951@163.com
2023-11-13 11:09:11 +00:00
committed by ob-robot
parent f966aaa116
commit 6ed7e537a0

View File

@ -125,8 +125,14 @@ public:
struct ObContextUnit struct ObContextUnit
{ {
inline void free(common::ObIAllocator &alloc) { inline void free(common::ObIAllocator &alloc) {
if (nullptr != value_.ptr()) {
alloc.free(value_.ptr()); alloc.free(value_.ptr());
value_.reset();
}
if (nullptr != attribute_.ptr()) {
alloc.free(attribute_.ptr()); alloc.free(attribute_.ptr());
attribute_.reset();
}
} }
int deep_copy(const common::ObString &attribute, int deep_copy(const common::ObString &attribute,
const common::ObString &value, const common::ObString &value,
@ -136,6 +142,7 @@ struct ObContextUnit
SQL_ENG_LOG(WARN, "failed to copy attribute", K(ret)); SQL_ENG_LOG(WARN, "failed to copy attribute", K(ret));
} else if (OB_FAIL(ob_write_string(alloc, value, value_))) { } else if (OB_FAIL(ob_write_string(alloc, value, value_))) {
alloc.free(attribute_.ptr()); alloc.free(attribute_.ptr());
attribute_.reset();
SQL_ENG_LOG(WARN, "failed to copy value", K(ret)); SQL_ENG_LOG(WARN, "failed to copy value", K(ret));
} }
return ret; return ret;
@ -458,9 +465,11 @@ struct ObInnerContextMap {
if (OB_NOT_NULL(context_map_)) { if (OB_NOT_NULL(context_map_)) {
context_map_->destroy(); context_map_->destroy();
alloc_.free(context_map_); alloc_.free(context_map_);
context_map_ = nullptr;
} }
if (OB_NOT_NULL(context_name_.ptr())) { if (OB_NOT_NULL(context_name_.ptr())) {
alloc_.free(context_name_.ptr()); alloc_.free(context_name_.ptr());
context_name_.reset();
} }
} }
int init() int init()