mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
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
1 changed files with 3 additions and 3 deletions
|
@ -489,13 +489,13 @@ PyInstance_New(class, arg, kw)
|
||||||
inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
|
inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
|
||||||
if (inst == NULL)
|
if (inst == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_INCREF(class);
|
|
||||||
inst->in_class = (PyClassObject *)class;
|
|
||||||
inst->in_dict = PyDict_New();
|
inst->in_dict = PyDict_New();
|
||||||
if (inst->in_dict == NULL) {
|
if (inst->in_dict == NULL) {
|
||||||
Py_DECREF(inst);
|
PyObject_DEL(inst);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Py_INCREF(class);
|
||||||
|
inst->in_class = (PyClassObject *)class;
|
||||||
if (initstr == NULL)
|
if (initstr == NULL)
|
||||||
initstr = PyString_InternFromString("__init__");
|
initstr = PyString_InternFromString("__init__");
|
||||||
init = instance_getattr2(inst, initstr);
|
init = instance_getattr2(inst, initstr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue