]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix memory leak in resultproxy.c
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 22 Apr 2022 14:27:38 +0000 (10:27 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 22 Apr 2022 14:31:10 +0000 (10:31 -0400)
the error raised for non-existent attribute didn't free
the "name" string, causing a leak.

Fixed a memory leak in the C extensions which could occur when calling upon
named members of :class:`.Row` when the member does not exist under Python
3; in particular this could occur during numpy transformations when it
attempts to call members such as ``.__array__``, but the issue was
surrounding any ``AttributeError`` thrown by the :class:`.Row` object. This
issue does not apply to version 2.0 which has already transitioned to
Cython. Thanks much to Sebastian Berg for identifying the problem.

Fixes: #7875
Change-Id: I444026a877ea1473a5ffac592c7f36ed6f4b563e

doc/build/changelog/unreleased_14/7875.rst [new file with mode: 0644]
lib/sqlalchemy/cextension/resultproxy.c

diff --git a/doc/build/changelog/unreleased_14/7875.rst b/doc/build/changelog/unreleased_14/7875.rst
new file mode 100644 (file)
index 0000000..a56fa80
--- /dev/null
@@ -0,0 +1,12 @@
+.. change::
+    :tags: bug, engine
+    :tickets: 7875
+
+    Fixed a memory leak in the C extensions which could occur when calling upon
+    named members of :class:`.Row` when the member does not exist under Python
+    3; in particular this could occur during numpy transformations when it
+    attempts to call members such as ``.__array__``, but the issue was
+    surrounding any ``AttributeError`` thrown by the :class:`.Row` object. This
+    issue does not apply to version 2.0 which has already transitioned to
+    Cython. Thanks much to Sebastian Berg for identifying the problem.
+
index c071ff3173154fdbe7a2aea157c9c7c30e7dec43..785ad7e807d7a93fc74e904b33d4ca166f9e3590 100644 (file)
@@ -541,6 +541,7 @@ BaseRow_getattro(BaseRow *self, PyObject *name)
                 "Could not locate column in row for column '%.200s'",
                 PyBytes_AS_STRING(err_bytes)
             );
+        Py_DECREF(err_bytes);
 #else
         PyErr_Format(
                 PyExc_AttributeError,