Skip to content

Commit ae02a92

Browse files
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 (cherry picked from commit 062a57b) Co-authored-by: Zackery Spytz <[email protected]>
1 parent e851049 commit ae02a92

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a possible segfault involving a newly-created coroutine. Patch by
2+
Zackery Spytz.

Objects/genobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,11 +1166,11 @@ PyCoro_New(PyFrameObject *f, PyObject *name, PyObject *qualname)
11661166
((PyCoroObject *)coro)->cr_origin = NULL;
11671167
} else {
11681168
PyObject *cr_origin = compute_cr_origin(origin_depth);
1169+
((PyCoroObject *)coro)->cr_origin = cr_origin;
11691170
if (!cr_origin) {
11701171
Py_DECREF(coro);
11711172
return NULL;
11721173
}
1173-
((PyCoroObject *)coro)->cr_origin = cr_origin;
11741174
}
11751175

11761176
return coro;

0 commit comments

Comments
 (0)