Skip to content

Commit cfee5fe

Browse files
committed
Fix: zero whole object in GraalPyPrivate_Tuple_Alloc
1 parent 4b77b68 commit cfee5fe

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

graalpython/com.oracle.graal.python.cext/src/tupleobject.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,12 +1326,19 @@ PyObject* GraalPyPrivate_Tuple_Alloc(PyTypeObject* type, Py_ssize_t nitems) {
13261326
if (alloc == NULL) {
13271327
return PyErr_NoMemory();
13281328
}
1329+
1330+
// GraalPy change: zero whole object
1331+
memset(alloc, '\0', size + presize);
1332+
13291333
obj = (PyObject *)(alloc + presize);
13301334
if (presize) {
1331-
// GraalPy change: different header layout, no GC link
1332-
((PyObject **)alloc)[0] = NULL;
1335+
// GraalPy change: different header layout
1336+
// ((PyObject **)alloc)[0] = NULL;
1337+
// ((PyObject **)alloc)[1] = NULL;
1338+
_PyObject_GC_Link(obj);
13331339
}
1334-
memset(obj, '\0', size);
1340+
// GraalPy change: whole memory is zero'd above
1341+
// memset(obj, '\0', size);
13351342

13361343
if (type->tp_itemsize == 0) {
13371344
_PyObject_Init(obj, type);

0 commit comments

Comments
 (0)