Skip to content

Commit 919d42d

Browse files
authored
bpo-31861: Fix possible crash in PyAnextAwaitable_New (GH-25005)
1 parent 57364ce commit 919d42d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Objects/iterobject.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ PyTypeObject PyAnextAwaitable_Type = {
368368
PyObject *
369369
PyAnextAwaitable_New(PyObject *awaitable, PyObject *default_value)
370370
{
371-
anextawaitableobject *anext = PyObject_GC_New(anextawaitableobject, &PyAnextAwaitable_Type);
371+
anextawaitableobject *anext = PyObject_GC_New(
372+
anextawaitableobject, &PyAnextAwaitable_Type);
373+
if (anext == NULL) {
374+
return NULL;
375+
}
372376
Py_INCREF(awaitable);
373377
anext->wrapped = awaitable;
374378
Py_INCREF(default_value);

0 commit comments

Comments
 (0)