Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa8efab

Browse files
committed
_PyObject_GC_New: Could call PyObject_INIT with a NULL 1st argument.
_PyObject_GC_NewVar: Could call PyObject_INIT_VAR likewise. Bugfix candidate.
1 parent 5de9842 commit fa8efab

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Modules/gcmodule.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,15 +878,19 @@ PyObject *
878878
_PyObject_GC_New(PyTypeObject *tp)
879879
{
880880
PyObject *op = _PyObject_GC_Malloc(_PyObject_SIZE(tp));
881-
return PyObject_INIT(op, tp);
881+
if (op != NULL)
882+
op = PyObject_INIT(op, tp);
883+
return op;
882884
}
883885

884886
PyVarObject *
885887
_PyObject_GC_NewVar(PyTypeObject *tp, int nitems)
886888
{
887889
const size_t size = _PyObject_VAR_SIZE(tp, nitems);
888890
PyVarObject *op = (PyVarObject *) _PyObject_GC_Malloc(size);
889-
return PyObject_INIT_VAR(op, tp, nitems);
891+
if (op != NULL)
892+
op = PyObject_INIT_VAR(op, tp, nitems);
893+
return op;
890894
}
891895

892896
PyVarObject *

0 commit comments

Comments
 (0)