From: Daniele Varrazzo Date: Thu, 16 Nov 2023 01:27:14 +0000 (+0100) Subject: fix: plug memory leak receiving notifications in python libpq wrapper X-Git-Tag: 3.2.0~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5019cb53e7509e2676109dfb04466818d4eecf9d;p=thirdparty%2Fpsycopg.git fix: plug memory leak receiving notifications in python libpq wrapper Close #679. --- diff --git a/docs/news.rst b/docs/news.rst index 7d63c0030..ecd88a12b 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -40,6 +40,8 @@ Psycopg 3.1.13 (unreleased) consistently with :pep:`475` guideline (:ticket:`#667`). - Fix support for connection strings with multiple hosts/ports and for the ``load_balance_hosts`` connection parameter (:ticket:`#674`). +- Fix memory leak receiving notifications in Python implementation + (:ticket:`#679`). Current release diff --git a/psycopg/psycopg/pq/pq_ctypes.py b/psycopg/psycopg/pq/pq_ctypes.py index 07c2d95cc..5f32031ca 100644 --- a/psycopg/psycopg/pq/pq_ctypes.py +++ b/psycopg/psycopg/pq/pq_ctypes.py @@ -604,8 +604,9 @@ class PGconn: ptr = impl.PQnotifies(self._pgconn_ptr) if ptr: c = ptr.contents - return PGnotify(c.relname, c.be_pid, c.extra) + rv = PGnotify(c.relname, c.be_pid, c.extra) impl.PQfreemem(ptr) + return rv else: return None