mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-35269: Fix a possible segfault involving a newly-created coroutine (GH-10585)
coro->cr_origin wasn't initialized if compute_cr_origin() failed in PyCoro_New(), which would cause a crash during the coroutine's deallocation. https://bugs.python.org/issue35269
This commit is contained in:
parent
177a41a07b
commit
062a57bf4b
2 changed files with 3 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
Fix a possible segfault involving a newly-created coroutine. Patch by
|
||||||
|
Zackery Spytz.
|
|
@ -1164,11 +1164,11 @@ PyCoro_New(PyFrameObject *f, PyObject *name, PyObject *qualname)
|
||||||
((PyCoroObject *)coro)->cr_origin = NULL;
|
((PyCoroObject *)coro)->cr_origin = NULL;
|
||||||
} else {
|
} else {
|
||||||
PyObject *cr_origin = compute_cr_origin(origin_depth);
|
PyObject *cr_origin = compute_cr_origin(origin_depth);
|
||||||
|
((PyCoroObject *)coro)->cr_origin = cr_origin;
|
||||||
if (!cr_origin) {
|
if (!cr_origin) {
|
||||||
Py_DECREF(coro);
|
Py_DECREF(coro);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
((PyCoroObject *)coro)->cr_origin = cr_origin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return coro;
|
return coro;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue