diff options
author | Georg Brandl <georg@python.org> | 2006-03-17 19:03:25 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-03-17 19:03:25 (GMT) |
commit | 5c170fd4a9d2bc2e475d718cbbce526cad4a3eaa (patch) | |
tree | 26fd8d333d8b7fdde9e4b4bb2c39082d9a3d29d0 /Objects | |
parent | a5a0704942fcd422f817c9b34e77a2346ddcf102 (diff) | |
download | cpython-5c170fd4a9d2bc2e475d718cbbce526cad4a3eaa.zip cpython-5c170fd4a9d2bc2e475d718cbbce526cad4a3eaa.tar.gz cpython-5c170fd4a9d2bc2e475d718cbbce526cad4a3eaa.tar.bz2 |
Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/tupleobject.c | 1 | ||||
-rw-r--r-- | Objects/typeobject.c | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 384b355..c16c71a 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -615,6 +615,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item) } else { result = PyTuple_New(slicelength); + if (!result) return NULL; src = self->ob_item; dest = ((PyTupleObject *)result)->ob_item; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 65bf404..e45a480 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1106,14 +1106,17 @@ set_mro_error(PyObject *to_merge, int *remain) char buf[1000]; PyObject *k, *v; PyObject *set = PyDict_New(); + if (!set) return; to_merge_size = PyList_GET_SIZE(to_merge); for (i = 0; i < to_merge_size; i++) { PyObject *L = PyList_GET_ITEM(to_merge, i); if (remain[i] < PyList_GET_SIZE(L)) { PyObject *c = PyList_GET_ITEM(L, remain[i]); - if (PyDict_SetItem(set, c, Py_None) < 0) + if (PyDict_SetItem(set, c, Py_None) < 0) { + Py_DECREF(set); return; + } } } n = PyDict_Size(set); |