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.
This commit is contained in:
parent
98626cd7ac
commit
d7823f2645
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue