From 364b0e0563e04c0e297667eb7cff82f175d2125e Mon Sep 17 00:00:00 2001 From: Kevin Michel Date: Mon, 4 May 2020 09:40:36 +0200 Subject: [PATCH 1/2] Fix memory leak in conn_set_client_encoding If the specified encoding is the same as the current one, the early exit did not release the clean_enc string allocated by clear_encoding_name. --- psycopg/connection_int.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 78dbd469..da8a4644 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -1389,7 +1389,10 @@ conn_set_client_encoding(connectionObject *self, const char *pgenc) /* If the current encoding is equal to the requested one we don't issue any query to the backend */ - if (strcmp(self->encoding, clean_enc) == 0) return 0; + if (strcmp(self->encoding, clean_enc) == 0) { + res = 0; + goto exit; + } Py_BEGIN_ALLOW_THREADS; pthread_mutex_lock(&self->lock); From a35549d0ad380a3a0b1726cc6ec723bc80b6ee01 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 4 May 2020 23:51:37 +1200 Subject: [PATCH 2/2] Mention ticket #1101 closed in news file --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index a1c56d05..08146516 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,13 @@ Current release --------------- +What's new in psycopg 2.8.6 +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Fixed memory leak changing connection encoding to the current one + (:ticket:`#1101`). + + What's new in psycopg 2.8.5 ^^^^^^^^^^^^^^^^^^^^^^^^^^^