mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
[3.11] gh-105375: Improve error handling in _ctypes (GH-105593) (#105664)
Prevent repeated PyLong_FromVoidPtr() from possibly overwriting the
current exception.
(cherry picked from commit e8998e46a7
)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
91877478ed
commit
a03449374e
2 changed files with 15 additions and 4 deletions
|
@ -499,12 +499,22 @@ long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
|||
|
||||
{
|
||||
PyObject *py_rclsid = PyLong_FromVoidPtr((void *)rclsid);
|
||||
if (py_rclsid == NULL) {
|
||||
Py_DECREF(func);
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
return E_FAIL;
|
||||
}
|
||||
PyObject *py_riid = PyLong_FromVoidPtr((void *)riid);
|
||||
if (py_riid == NULL) {
|
||||
Py_DECREF(func);
|
||||
Py_DECREF(py_rclsid);
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
return E_FAIL;
|
||||
}
|
||||
PyObject *py_ppv = PyLong_FromVoidPtr(ppv);
|
||||
if (!py_rclsid || !py_riid || !py_ppv) {
|
||||
Py_XDECREF(py_rclsid);
|
||||
Py_XDECREF(py_riid);
|
||||
Py_XDECREF(py_ppv);
|
||||
if (py_ppv == NULL) {
|
||||
Py_DECREF(py_rclsid);
|
||||
Py_DECREF(py_riid);
|
||||
Py_DECREF(func);
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
return E_FAIL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue