Skip to content

Commit 062a57b

Browse files
ZackerySpytzmiss-islington
authored andcommitted
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
1 parent 177a41a commit 062a57b

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
@@ -1164,11 +1164,11 @@ PyCoro_New(PyFrameObject *f, PyObject *name, PyObject *qualname)
11641164
((PyCoroObject *)coro)->cr_origin = NULL;
11651165
} else {
11661166
PyObject *cr_origin = compute_cr_origin(origin_depth);
1167+
((PyCoroObject *)coro)->cr_origin = cr_origin;
11671168
if (!cr_origin) {
11681169
Py_DECREF(coro);
11691170
return NULL;
11701171
}
1171-
((PyCoroObject *)coro)->cr_origin = cr_origin;
11721172
}
11731173

11741174
return coro;

0 commit comments

Comments
 (0)