Fix refcounting issue with python frame objects

This commit is contained in:
baldurk
2022-11-09 12:20:48 +00:00
parent 742e3de252
commit 2cf7b911c7
@@ -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)
{