From: Victor Stinner Date: Tue, 29 Oct 2013 18:28:20 +0000 (+0100) Subject: Cleanup locale.localeconv(): move Py_DECREF() closer to the error X-Git-Tag: v3.4.0b1~480^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f38a5c28e0f032e6eb9bab7c178f43f0bd2cad8d;p=python Cleanup locale.localeconv(): move Py_DECREF() closer to the error --- diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index b196749aec..400c3448ba 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -151,8 +151,10 @@ PyLocale_localeconv(PyObject* self) do { \ if (obj == NULL) \ goto failed; \ - if (PyDict_SetItemString(result, key, obj) < 0) \ + if (PyDict_SetItemString(result, key, obj) < 0) { \ + Py_DECREF(obj); \ goto failed; \ + } \ Py_DECREF(obj); \ } while (0) @@ -196,7 +198,6 @@ PyLocale_localeconv(PyObject* self) failed: Py_XDECREF(result); - Py_XDECREF(x); return NULL; }