diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-11-17-10-18-29.bpo-35269.gjm1LO.rst b/Misc/NEWS.d/next/Core and Builtins/2018-11-17-10-18-29.bpo-35269.gjm1LO.rst new file mode 100644 index 00000000000..0076346f4b6 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2018-11-17-10-18-29.bpo-35269.gjm1LO.rst @@ -0,0 +1,2 @@ +Fix a possible segfault involving a newly-created coroutine. Patch by +Zackery Spytz. diff --git a/Objects/genobject.c b/Objects/genobject.c index e91d11114d3..793a809b842 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -1166,11 +1166,11 @@ PyCoro_New(PyFrameObject *f, PyObject *name, PyObject *qualname) ((PyCoroObject *)coro)->cr_origin = NULL; } else { PyObject *cr_origin = compute_cr_origin(origin_depth); + ((PyCoroObject *)coro)->cr_origin = cr_origin; if (!cr_origin) { Py_DECREF(coro); return NULL; } - ((PyCoroObject *)coro)->cr_origin = cr_origin; } return coro;