[Python-checkins] cpython: Cleanup locale.localeconv(): move Py_DECREF() closer to the error

victor.stinner python-checkins at python.org
Tue Oct 29 19:45:52 CET 2013


http://hg.python.org/cpython/rev/deae3c6a88f0
changeset:   86742:deae3c6a88f0
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Oct 29 19:28:20 2013 +0100
summary:
  Cleanup locale.localeconv(): move Py_DECREF() closer to the error

files:
  Modules/_localemodule.c |  5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -151,8 +151,10 @@
     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 @@
 
   failed:
     Py_XDECREF(result);
-    Py_XDECREF(x);
     return NULL;
 }
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list