From 13f2d9217ee5c03a724d4dab51e3b022e74a6c53 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 5 Jul 2019 18:31:08 +0900 Subject: [PATCH 1/2] bpo-37483: fix refleak --- Python/codecs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/codecs.c b/Python/codecs.c index 386576256f06553..ef08326f70b6264 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -175,9 +175,11 @@ PyObject *_PyCodec_Lookup(const char *encoding) Py_DECREF(result); goto onError; } + Py_DECREF(v); return result; onError: + Py_DECREF(v); return NULL; } From 2aab0618464ce40ef4dfb17c5cb331380d5831c0 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 5 Jul 2019 19:31:47 +0900 Subject: [PATCH 2/2] move variable declaration --- Python/codecs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/codecs.c b/Python/codecs.c index ef08326f70b6264..6d9f63cf49c83fe 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -99,7 +99,7 @@ PyObject *normalizestring(const char *string) PyObject *_PyCodec_Lookup(const char *encoding) { - PyObject *result, *v; + PyObject *result; Py_ssize_t i, len; if (encoding == NULL) { @@ -114,7 +114,7 @@ PyObject *_PyCodec_Lookup(const char *encoding) /* Convert the encoding to a normalized Python string: all characters are converted to lower case, spaces and hyphens are replaced with underscores. */ - v = normalizestring(encoding); + PyObject *v = normalizestring(encoding); if (v == NULL) goto onError; PyUnicode_InternInPlace(&v);