sip4: fix memleak with Python 3.11

This commit is contained in:
Đoàn Trần Công Danh 2022-09-24 13:55:37 +07:00
parent c9b446f7c5
commit e97b043c1b

View File

@ -20,7 +20,7 @@
static int sip_api_check_plugin_for_type(const sipTypeDef *td,
const char *name);
static PyObject *sip_api_unicode_new(SIP_SSIZE_T len, unsigned maxchar,
@@ -13741,13 +13741,13 @@ static int sip_api_is_user_type(const si
@@ -13741,13 +13741,16 @@ static int sip_api_is_user_type(const si
/*
* Return a frame from the execution stack.
*/
@ -29,11 +29,14 @@
{
- struct _frame *frame = PyEval_GetFrame();
+ PyFrameObject *frame = PyEval_GetFrame();
+ Py_XINCREF(frame);
while (frame != NULL && depth > 0)
{
- frame = frame->f_back;
+ PyFrameObject *oframe = frame;
+ frame = PyFrame_GetBack(frame);
+ Py_DECREF(oframe);
--depth;
}