mirror of
https://github.com/python/cpython.git
synced 2026-01-04 06:22:20 +00:00
gh-127870: Detect recursive calls in ctypes _as_parameter_ handling (#127872)
This commit is contained in:
parent
e62e1ca455
commit
6ff38fc4e2
3 changed files with 33 additions and 3 deletions
|
|
@ -1052,8 +1052,13 @@ CDataType_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value)
|
|||
return NULL;
|
||||
}
|
||||
if (as_parameter) {
|
||||
if (_Py_EnterRecursiveCall(" while processing _as_parameter_")) {
|
||||
Py_DECREF(as_parameter);
|
||||
return NULL;
|
||||
}
|
||||
value = CDataType_from_param_impl(type, cls, as_parameter);
|
||||
Py_DECREF(as_parameter);
|
||||
_Py_LeaveRecursiveCall();
|
||||
return value;
|
||||
}
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
|
@ -1843,8 +1848,13 @@ c_wchar_p_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value)
|
|||
return NULL;
|
||||
}
|
||||
if (as_parameter) {
|
||||
if (_Py_EnterRecursiveCall(" while processing _as_parameter_")) {
|
||||
Py_DECREF(as_parameter);
|
||||
return NULL;
|
||||
}
|
||||
value = c_wchar_p_from_param_impl(type, cls, as_parameter);
|
||||
Py_DECREF(as_parameter);
|
||||
_Py_LeaveRecursiveCall();
|
||||
return value;
|
||||
}
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
|
@ -1927,8 +1937,13 @@ c_char_p_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value)
|
|||
return NULL;
|
||||
}
|
||||
if (as_parameter) {
|
||||
if (_Py_EnterRecursiveCall(" while processing _as_parameter_")) {
|
||||
Py_DECREF(as_parameter);
|
||||
return NULL;
|
||||
}
|
||||
value = c_char_p_from_param_impl(type, cls, as_parameter);
|
||||
Py_DECREF(as_parameter);
|
||||
_Py_LeaveRecursiveCall();
|
||||
return value;
|
||||
}
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
|
@ -2079,8 +2094,13 @@ c_void_p_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value)
|
|||
return NULL;
|
||||
}
|
||||
if (as_parameter) {
|
||||
if (_Py_EnterRecursiveCall(" while processing _as_parameter_")) {
|
||||
Py_DECREF(as_parameter);
|
||||
return NULL;
|
||||
}
|
||||
value = c_void_p_from_param_impl(type, cls, as_parameter);
|
||||
Py_DECREF(as_parameter);
|
||||
_Py_LeaveRecursiveCall();
|
||||
return value;
|
||||
}
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
|
@ -2447,9 +2467,9 @@ PyCSimpleType_from_param_impl(PyObject *type, PyTypeObject *cls,
|
|||
return NULL;
|
||||
}
|
||||
value = PyCSimpleType_from_param_impl(type, cls, as_parameter);
|
||||
_Py_LeaveRecursiveCall();
|
||||
Py_DECREF(as_parameter);
|
||||
Py_XDECREF(exc);
|
||||
_Py_LeaveRecursiveCall();
|
||||
return value;
|
||||
}
|
||||
if (exc) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue