]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix refleaks
authorBenjamin Peterson <benjamin@python.org>
Thu, 14 Nov 2013 04:49:49 +0000 (23:49 -0500)
committerBenjamin Peterson <benjamin@python.org>
Thu, 14 Nov 2013 04:49:49 +0000 (23:49 -0500)
Objects/exceptions.c

index 53dab6224a23596477e9ab0c3c8f4075c3c34859..8b109703f7d5b01d475afb33b5135d843381c9bc 100644 (file)
@@ -2683,6 +2683,9 @@ _PyErr_TrySetFromCause(const char *format, ...)
      * state potentially stored on OSError instances.
      */
 
+    Py_DECREF(exc);
+    Py_XDECREF(tb);
+
 #ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
 #else
@@ -2690,13 +2693,14 @@ _PyErr_TrySetFromCause(const char *format, ...)
 #endif
     msg_prefix = PyUnicode_FromFormatV(format, vargs);
     va_end(vargs);
-    if (msg_prefix == NULL)
+    if (msg_prefix == NULL) {
+        Py_DECREF(val);
         return NULL;
+    }
 
     PyErr_Format(exc, "%U (%s: %S)",
                  msg_prefix, Py_TYPE(val)->tp_name, val);
-    Py_DECREF(exc);
-    Py_XDECREF(tb);
+    Py_DECREF(msg_prefix);
     PyErr_Fetch(&new_exc, &new_val, &new_tb);
     PyErr_NormalizeException(&new_exc, &new_val, &new_tb);
     PyException_SetCause(new_val, val);