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.1.13~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c22a1651fa5bf062f945049618e211a0d5d66f73;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 0ecea1996..e03637897 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -20,6 +20,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 204e38484..fdf2ad8a8 100644 --- a/psycopg/psycopg/pq/pq_ctypes.py +++ b/psycopg/psycopg/pq/pq_ctypes.py @@ -568,8 +568,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