diff --git a/Python/codecs.c b/Python/codecs.c index 386576256f06553..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); @@ -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; }