[Python-checkins] cpython: Fix refleaks if Py_EnterRecursiveCall() fails

victor.stinner python-checkins at python.org
Wed Feb 8 07:08:40 EST 2017


https://hg.python.org/cpython/rev/37705f89c72b
changeset:   106470:37705f89c72b
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Feb 08 12:57:09 2017 +0100
summary:
  Fix refleaks if Py_EnterRecursiveCall() fails

Issue #29306: Destroy argstuple and kwdict if Py_EnterRecursiveCall() fails.

files:
  Objects/abstract.c |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2350,14 +2350,15 @@
         }
 
         if (Py_EnterRecursiveCall(" while calling a Python object")) {
+            Py_DECREF(argstuple);
             return NULL;
         }
 
         result = (*call)(callable, argstuple, kwargs);
 
         Py_LeaveRecursiveCall();
-
         Py_DECREF(argstuple);
+
         result = _Py_CheckFunctionResult(callable, result, NULL);
         return result;
     }
@@ -2544,6 +2545,8 @@
         }
 
         if (Py_EnterRecursiveCall(" while calling a Python object")) {
+            Py_DECREF(argstuple);
+            Py_XDECREF(kwdict);
             return NULL;
         }
 

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


More information about the Python-checkins mailing list