]> granicus.if.org Git - python/commitdiff
_PyObject_GC_New: Could call PyObject_INIT with a NULL 1st argument.
authorTim Peters <tim.peters@gmail.com>
Sun, 28 Apr 2002 01:57:25 +0000 (01:57 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 28 Apr 2002 01:57:25 +0000 (01:57 +0000)
_PyObject_GC_NewVar:  Could call PyObject_INIT_VAR likewise.

Bugfix candidate.

Modules/gcmodule.c

index 66f70326975c7068d1a050d9594d4a4df9b56fd2..fd9f265c8387e65bc713802535401a5a5d8b7130 100644 (file)
@@ -878,7 +878,9 @@ PyObject *
 _PyObject_GC_New(PyTypeObject *tp)
 {
        PyObject *op = _PyObject_GC_Malloc(_PyObject_SIZE(tp));
-       return PyObject_INIT(op, tp);
+       if (op != NULL)
+               op = PyObject_INIT(op, tp);
+       return op;
 }
 
 PyVarObject *
@@ -886,7 +888,9 @@ _PyObject_GC_NewVar(PyTypeObject *tp, int nitems)
 {
        const size_t size = _PyObject_VAR_SIZE(tp, nitems);
        PyVarObject *op = (PyVarObject *) _PyObject_GC_Malloc(size);
-       return PyObject_INIT_VAR(op, tp, nitems);
+       if (op != NULL)
+               op = PyObject_INIT_VAR(op, tp, nitems);
+       return op;
 }
 
 PyVarObject *