From e1155848a140d2ded622f4d37d34bd2ab5e62cfd Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 14 Dec 2023 09:13:05 +0000 Subject: [PATCH] [to #53517978] fix memory leak with collection element assign to null --- src/sql/ob_spi.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index 4ba0a2c00f..92dd5f3eb4 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -5668,10 +5668,13 @@ int ObSPIService::spi_reset_collection(ObPLCollection *coll) * ORA-06531: Reference to uninitialized collection * ORA-06512: at line 6 * */ - coll->set_count(OB_INVALID_COUNT); - coll->set_first(OB_INVALID_INDEX); - coll->set_last(OB_INVALID_INDEX); - coll->set_data(NULL); + if (OB_NOT_NULL(coll->get_allocator())) { + OZ (spi_set_collection(MTL_ID(), NULL, *(coll->get_allocator()), *coll, 0, false)); + OX (coll->set_count(OB_INVALID_COUNT)); + } else { + CK (coll->get_count() == 0 || coll->get_count() == OB_INVALID_COUNT); + OX (coll->set_count(OB_INVALID_COUNT)); + } } return ret; }