Kaydet (Commit) 28f35f24 authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka

Issue #25961: Fixed compilation error and a leak in type constructor.

üst f9347e3b
...@@ -2342,12 +2342,17 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) ...@@ -2342,12 +2342,17 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
type->tp_as_mapping = &et->as_mapping; type->tp_as_mapping = &et->as_mapping;
type->tp_as_buffer = &et->as_buffer; type->tp_as_buffer = &et->as_buffer;
type->tp_name = PyString_AS_STRING(name); type->tp_name = PyString_AS_STRING(name);
if (!type->tp_name) if (!type->tp_name) {
goto error; Py_DECREF(bases);
Py_DECREF(type);
return NULL;
}
if (strlen(type->tp_name) != (size_t)PyString_GET_SIZE(name)) { if (strlen(type->tp_name) != (size_t)PyString_GET_SIZE(name)) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"type name must not contain null characters"); "type name must not contain null characters");
goto error; Py_DECREF(bases);
Py_DECREF(type);
return NULL;
} }
/* Set tp_base and tp_bases */ /* Set tp_base and tp_bases */
...@@ -2369,8 +2374,10 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) ...@@ -2369,8 +2374,10 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
tmp = PyDict_GetItemString(tmp, "__name__"); tmp = PyDict_GetItemString(tmp, "__name__");
if (tmp != NULL) { if (tmp != NULL) {
if (PyDict_SetItemString(dict, "__module__", if (PyDict_SetItemString(dict, "__module__",
tmp) < 0) tmp) < 0) {
Py_DECREF(type);
return NULL; return NULL;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment