From 6ed7e537a0036969a7a14cb4cac7c48237d2130e Mon Sep 17 00:00:00 2001 From: "18523270951@163.com" <18523270951@163.com> Date: Mon, 13 Nov 2023 11:09:11 +0000 Subject: [PATCH] fix context core because of double free --- src/sql/session/ob_sql_session_info.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sql/session/ob_sql_session_info.h b/src/sql/session/ob_sql_session_info.h index 560d85645..061317f7f 100644 --- a/src/sql/session/ob_sql_session_info.h +++ b/src/sql/session/ob_sql_session_info.h @@ -125,8 +125,14 @@ public: struct ObContextUnit { inline void free(common::ObIAllocator &alloc) { - alloc.free(value_.ptr()); - alloc.free(attribute_.ptr()); + if (nullptr != value_.ptr()) { + alloc.free(value_.ptr()); + value_.reset(); + } + if (nullptr != attribute_.ptr()) { + alloc.free(attribute_.ptr()); + attribute_.reset(); + } } int deep_copy(const common::ObString &attribute, const common::ObString &value, @@ -136,6 +142,7 @@ struct ObContextUnit SQL_ENG_LOG(WARN, "failed to copy attribute", K(ret)); } else if (OB_FAIL(ob_write_string(alloc, value, value_))) { alloc.free(attribute_.ptr()); + attribute_.reset(); SQL_ENG_LOG(WARN, "failed to copy value", K(ret)); } return ret; @@ -458,9 +465,11 @@ struct ObInnerContextMap { if (OB_NOT_NULL(context_map_)) { context_map_->destroy(); alloc_.free(context_map_); + context_map_ = nullptr; } if (OB_NOT_NULL(context_name_.ptr())) { alloc_.free(context_name_.ptr()); + context_name_.reset(); } } int init()