Skip to content

Commit cfee4d2

Browse files
committed
Resolve more comments on the PR 154019
1 parent 15ee20d commit cfee4d2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Fix a crash in the free-threaded build where :c:func:`PyList_New` could leave
1+
Fix a crash in the :term:`free-threaded` build where :c:func:`PyList_New` could leave
22
a newly allocated list's item buffer pointer uninitialized when the backing
33
array allocation failed under low memory, leading to an invalid free.

Objects/listobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ PyList_New(Py_ssize_t size)
253253
}
254254
}
255255
op->ob_item = NULL;
256+
Py_SET_SIZE(op, size);
257+
op->allocated = size;
256258

257259
if (size > 0) {
258260
#ifdef Py_GIL_DISABLED
@@ -271,8 +273,6 @@ PyList_New(Py_ssize_t size)
271273
return PyErr_NoMemory();
272274
}
273275
}
274-
Py_SET_SIZE(op, size);
275-
op->allocated = size;
276276
_PyObject_GC_TRACK(op);
277277
return (PyObject *) op;
278278
}

0 commit comments

Comments
 (0)