From f38a5c28e0f032e6eb9bab7c178f43f0bd2cad8d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 29 Oct 2013 19:28:20 +0100 Subject: Cleanup locale.localeconv(): move Py_DECREF() closer to the error --- Modules/_localemodule.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index b196749..400c344 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; } -- cgit v0.12