summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-31 12:03:14 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-31 12:03:14 +0200
commit28f35f246b1bc030bd3f2ed0ca1010412dee2273 (patch)
tree133575a4a16f20654cfecdbfc9def1a7963d47a6
parentf9347e3b44425c1cb357a0ae76e8756c5894d6c6 (diff)
downloadcpython-git-28f35f246b1bc030bd3f2ed0ca1010412dee2273.tar.gz
Issue #25961: Fixed compilation error and a leak in type constructor.
-rw-r--r--Objects/typeobject.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 278e485df5..8375f5fdad 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2342,12 +2342,17 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
type->tp_as_mapping = &et->as_mapping;
type->tp_as_buffer = &et->as_buffer;
type->tp_name = PyString_AS_STRING(name);
- if (!type->tp_name)
- goto error;
+ if (!type->tp_name) {
+ Py_DECREF(bases);
+ Py_DECREF(type);
+ return NULL;
+ }
if (strlen(type->tp_name) != (size_t)PyString_GET_SIZE(name)) {
PyErr_SetString(PyExc_ValueError,
"type name must not contain null characters");
- goto error;
+ Py_DECREF(bases);
+ Py_DECREF(type);
+ return NULL;
}
/* Set tp_base and tp_bases */
@@ -2369,8 +2374,10 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
tmp = PyDict_GetItemString(tmp, "__name__");
if (tmp != NULL) {
if (PyDict_SetItemString(dict, "__module__",
- tmp) < 0)
+ tmp) < 0) {
+ Py_DECREF(type);
return NULL;
+ }
}
}
}