]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport tim_one's patch:
authorAnthony Baxter <anthonybaxter@gmail.com>
Tue, 30 Apr 2002 03:33:15 +0000 (03:33 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Tue, 30 Apr 2002 03:33:15 +0000 (03:33 +0000)
(some tweaking for different _PyObject_GC_Malloc() call in 2.2. checked,
still returns the same thing on failure...)

_PyObject_GC_New:  Could call PyObject_INIT with a NULL 1st argument.
_PyObject_GC_NewVar:  Could call PyObject_INIT_VAR likewise.

Bugfix candidate.

Original patch(es):
python/dist/src/Modules/gcmodule.c:2.40

Modules/gcmodule.c

index e3bb669d361532a1258977f9c512b5d52861a8b5..83fb8747bddc5a1ee69103be4c781c82161bdd79 100644 (file)
@@ -861,14 +861,18 @@ PyObject *
 _PyObject_GC_New(PyTypeObject *tp)
 {
        PyObject *op = _PyObject_GC_Malloc(tp, 0);
-       return PyObject_INIT(op, tp);
+       if (op != NULL)
+               op = PyObject_INIT(op, tp);
+       return op;
 }
 
 PyVarObject *
 _PyObject_GC_NewVar(PyTypeObject *tp, int nitems)
 {
        PyVarObject *op = (PyVarObject *) _PyObject_GC_Malloc(tp, nitems);
-       return PyObject_INIT_VAR(op, tp, nitems);
+       if (op != NULL)
+               op = PyObject_INIT_VAR(op, tp, nitems);
+       return op;
 }
 
 PyVarObject *