]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34190: Fix reference leak in call_function() (GH-8413) (GH-8418)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 23 Jul 2018 21:45:26 +0000 (14:45 -0700)
committerVictor Stinner <vstinner@redhat.com>
Mon, 23 Jul 2018 21:45:26 +0000 (23:45 +0200)
(cherry picked from commit 147d95511f59cfdd2d522f9d736f2335457bae20)

Co-authored-by: jdemeyer <jdemeyer@cage.ugent.be>
Python/ceval.c

index 600147b7aaf210f6c4be18aaebd22192043e6cee..0d1519bef4f0f254478860bf9a5d2ccf1d393215 100644 (file)
@@ -4565,12 +4565,15 @@ call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
                profiling. */
             PyObject *self = stack[0];
             func = Py_TYPE(func)->tp_descr_get(func, self, (PyObject*)Py_TYPE(self));
-            if (func == NULL) {
-                return NULL;
+            if (func != NULL) {
+                C_TRACE(x, _PyCFunction_FastCallKeywords(func,
+                                                         stack+1, nargs-1,
+                                                         kwnames));
+                Py_DECREF(func);
+            }
+            else {
+                x = NULL;
             }
-            C_TRACE(x, _PyCFunction_FastCallKeywords(func, stack+1, nargs-1,
-                                                     kwnames));
-            Py_DECREF(func);
         }
         else {
             x = _PyMethodDescr_FastCallKeywords(func, stack, nargs, kwnames);