From 48b76bc0e52c752b4cdcfc317d4cf1d115a3b64b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 8 Jan 2021 15:01:38 +0100 Subject: [PATCH] bpo-42866: Fix refleak in CJK getcodec() (GH-24165) Fix a reference leak in the getcodec() function of CJK codecs. (cherry picked from commit e542d417b96077d04aec089505eacb990c9799ae) Co-authored-by: Victor Stinner --- .../next/Library/2021-01-08-10-57-21.bpo-42866.Y1DnrO.rst | 2 ++ Modules/cjkcodecs/cjkcodecs.h | 1 + 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2021-01-08-10-57-21.bpo-42866.Y1DnrO.rst 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 00000000000000..3ea6cc239aa694 --- /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 b67f3482faf8da..0dcd4b85525feb 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -293,6 +293,7 @@ getcodec(PyObject *self, PyObject *encoding) r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL); Py_DECREF(codecobj); + Py_DECREF(cofunc); return r; }