summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-07-21 05:32:28 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-07-21 05:32:28 (GMT)
commite1fdb32ff2bb1f4b46b56fc1de03f8016bc6c780 (patch)
treecd676947643217e1aaaa4723beecc6313d9d15b6 /Objects
parent1adbb507013bea05cda92ea6aa9a8fef72657923 (diff)
downloadcpython-e1fdb32ff2bb1f4b46b56fc1de03f8016bc6c780.zip
cpython-e1fdb32ff2bb1f4b46b56fc1de03f8016bc6c780.tar.gz
cpython-e1fdb32ff2bb1f4b46b56fc1de03f8016bc6c780.tar.bz2
Handle allocation failures gracefully. Found with failmalloc.
Many (all?) of these could be backported.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c2
-rw-r--r--Objects/unicodeobject.c3
2 files changed, 5 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 2046972..6b48430 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3260,6 +3260,8 @@ PyType_Ready(PyTypeObject *type)
if (PyDict_GetItemString(type->tp_dict, "__doc__") == NULL) {
if (type->tp_doc != NULL) {
PyObject *doc = PyString_FromString(type->tp_doc);
+ if (doc == NULL)
+ goto error;
PyDict_SetItemString(type->tp_dict, "__doc__", doc);
Py_DECREF(doc);
} else {
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 08fdb3f..096dfc6 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -7918,6 +7918,9 @@ void _PyUnicode_Init(void)
unicode_freelist = NULL;
unicode_freelist_size = 0;
unicode_empty = _PyUnicode_New(0);
+ if (!unicode_empty)
+ return;
+
strcpy(unicode_default_encoding, "ascii");
for (i = 0; i < 256; i++)
unicode_latin1[i] = NULL;