Skip to content

Commit 65b1339

Browse files
Fixed memory leak when accessing objects embedded within other objects.
1 parent 929bff9 commit 65b1339

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

doc/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Thick Mode Changes
6060
#) Relaxed restriction for end-to-end string connection attributes. These
6161
values can be set to the value ``None`` which will be treated the same as
6262
an empty string.
63+
#) Fixed memory leak when accessing objects embedded within other objects.
6364

6465
Common Changes
6566
++++++++++++++

src/oracledb/impl/thick/dbobject.pyx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2023, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -114,8 +114,12 @@ cdef class ThickDbObjectImpl(BaseDbObjectImpl):
114114
if data.isNull:
115115
return None
116116
type_impl = self.type
117-
return _convert_to_python(type_impl._conn_impl, attr.dbtype,
118-
attr.objtype, &data.value)
117+
try:
118+
return _convert_to_python(type_impl._conn_impl, attr.dbtype,
119+
attr.objtype, &data.value)
120+
finally:
121+
if attr.objtype is not None:
122+
dpiObject_release(data.value.asObject)
119123

120124
def get_element_by_index(self, int32_t index):
121125
"""
@@ -138,8 +142,13 @@ cdef class ThickDbObjectImpl(BaseDbObjectImpl):
138142
_raise_from_odpi()
139143
if data.isNull:
140144
return None
141-
return _convert_to_python(objtype._conn_impl, objtype.element_dbtype,
142-
objtype.element_objtype, &data.value)
145+
try:
146+
return _convert_to_python(objtype._conn_impl,
147+
objtype.element_dbtype,
148+
objtype.element_objtype, &data.value)
149+
finally:
150+
if objtype.element_objtype is not None:
151+
dpiObject_release(data.value.asObject)
143152

144153
def get_first_index(self):
145154
"""

0 commit comments

Comments
 (0)