summaryrefslogtreecommitdiff
path: root/psycopg/connection_int.c
diff options
context:
space:
mode:
authorKevin Michel <kevin.michel@sereema.com>2020-05-04 09:40:36 +0200
committerKevin Michel <kevin.michel@sereema.com>2020-05-04 09:40:36 +0200
commit364b0e0563e04c0e297667eb7cff82f175d2125e (patch)
treea274ec010f9a2d9e144351ec120d3d0e4bd01705 /psycopg/connection_int.c
parent8b2450287ee5ce22e5fd30f60d8117e989e8ba29 (diff)
downloadpsycopg2-364b0e0563e04c0e297667eb7cff82f175d2125e.tar.gz
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.
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r--psycopg/connection_int.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
index 78dbd46..da8a464 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);