]> granicus.if.org Git - python/commitdiff
Cleanup locale.localeconv(): move Py_DECREF() closer to the error
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Oct 2013 18:28:20 +0000 (19:28 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Oct 2013 18:28:20 +0000 (19:28 +0100)
Modules/_localemodule.c

index b196749aecc95b2506e06d67deafac19e1ce803f..400c3448baba5cd442550401bc405f9f52c7750b 100644 (file)
@@ -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;
 }