From 2cf7b911c7fb772e3f1e1cd4f4aa5c3a6b704d52 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 9 Nov 2022 12:20:48 +0000 Subject: [PATCH] Fix refcounting issue with python frame objects --- qrenderdoc/Code/pyrenderdoc/PythonContext.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp b/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp index 6cbcc7ee5..40b9cb47a 100644 --- a/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp +++ b/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp @@ -1247,6 +1247,9 @@ PyObject *PythonContext::outstream_write(PyObject *self, PyObject *args) if(context == NULL) { PyFrameObject *frame = PyEval_GetFrame(); + // inc reference count here so all frames can be decref'd whether they come from here or + // PyFrame_GetBack + Py_XINCREF(frame); while(frame) { @@ -1366,6 +1369,9 @@ extern "C" PyObject *GetCurrentGlobalHandle() // module the globals may not have the entry, but the root level is expected to. { PyFrameObject *frame = PyEval_GetFrame(); + // inc reference count here so all frames can be decref'd whether they come from here or + // PyFrame_GetBack + Py_XINCREF(frame); while(frame) {