[Python-checkins] bpo-42866: Fix refleak in CJK getcodec() (GH-24165)

vstinner webhook-mailer at python.org
Fri Jan 8 09:01:50 EST 2021


https://github.com/python/cpython/commit/e542d417b96077d04aec089505eacb990c9799ae
commit: e542d417b96077d04aec089505eacb990c9799ae
branch: master
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2021-01-08T15:01:38+01:00
summary:

bpo-42866: Fix refleak in CJK getcodec() (GH-24165)

Fix a reference leak in the getcodec() function of CJK codecs.

files:
A Misc/NEWS.d/next/Library/2021-01-08-10-57-21.bpo-42866.Y1DnrO.rst
M Modules/cjkcodecs/cjkcodecs.h

diff --git a/Misc/NEWS.d/next/Library/2021-01-08-10-57-21.bpo-42866.Y1DnrO.rst b/Misc/NEWS.d/next/Library/2021-01-08-10-57-21.bpo-42866.Y1DnrO.rst
new file mode 100644
index 0000000000000..3ea6cc239aa69
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-01-08-10-57-21.bpo-42866.Y1DnrO.rst
@@ -0,0 +1,2 @@
+Fix a reference leak in the ``getcodec()`` function of CJK codecs. Patch by
+Victor Stinner.
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h
index 3b89bc93ed142..ba8fad26055a8 100644
--- a/Modules/cjkcodecs/cjkcodecs.h
+++ b/Modules/cjkcodecs/cjkcodecs.h
@@ -291,6 +291,7 @@ getcodec(PyObject *self, PyObject *encoding)
 
     r = PyObject_CallOneArg(cofunc, codecobj);
     Py_DECREF(codecobj);
+    Py_DECREF(cofunc);
 
     return r;
 }



More information about the Python-checkins mailing list