From d7823f264570fb94f179e453330ea12f6158e2e5 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 28 Jun 2000 23:46:07 +0000 Subject: Vladimir Marangozov: Avoid calling the dealloc function, previously triggered with DECREF(inst). This caused a segfault in PyDict_GetItem, called with a NULL dict, whenever inst->in_dict fails under low-memory conditions. --- Objects/classobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/classobject.c b/Objects/classobject.c index 9e1d1b2..cd0bb1d 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -489,13 +489,13 @@ PyInstance_New(class, arg, kw) inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) return NULL; - Py_INCREF(class); - inst->in_class = (PyClassObject *)class; inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { - Py_DECREF(inst); + PyObject_DEL(inst); return NULL; } + Py_INCREF(class); + inst->in_class = (PyClassObject *)class; if (initstr == NULL) initstr = PyString_InternFromString("__init__"); init = instance_getattr2(inst, initstr); -- cgit v0.12