changeset: 99729:57fea6f75ac2 branch: 2.7 parent: 99726:29cc6b2f9d28 user: Serhiy Storchaka date: Thu Dec 31 12:03:14 2015 +0200 files: Objects/typeobject.c description: Issue #25961: Fixed compilation error and a leak in type constructor. diff -r 29cc6b2f9d28 -r 57fea6f75ac2 Objects/typeobject.c --- a/Objects/typeobject.c Wed Dec 30 21:39:21 2015 +0200 +++ b/Objects/typeobject.c Thu Dec 31 12:03:14 2015 +0200 @@ -2342,12 +2342,17 @@ 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 @@ tmp = PyDict_GetItemString(tmp, "__name__"); if (tmp != NULL) { if (PyDict_SetItemString(dict, "__module__", - tmp) < 0) + tmp) < 0) { + Py_DECREF(type); return NULL; + } } } }