From: Neal Norwitz Date: Sun, 2 Feb 2003 19:25:22 +0000 (+0000) Subject: backport: X-Git-Tag: v2.2.3c1~157 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6b5140f9927904132e25fdf889b6889302110703;p=thirdparty%2FPython%2Fcpython.git backport: revision 1.11 date: 2002/12/18 23:20:39; author: nnorwitz; state: Exp; lines: +6 -2 SF # 654974, fix unchecked return values in structseq Check return values after memory allocation. --- diff --git a/Objects/structseq.c b/Objects/structseq.c index 377dfebd2ed5..26cd5eef0dc7 100644 --- a/Objects/structseq.c +++ b/Objects/structseq.c @@ -140,6 +140,9 @@ structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } res = (PyStructSequence*) PyStructSequence_New(type); + if (res == NULL) { + return NULL; + } for (i = 0; i < len; ++i) { PyObject *v = PySequence_Fast_GET_ITEM(arg, i); Py_INCREF(v); @@ -346,6 +349,8 @@ PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc) type->tp_itemsize = 0; members = PyMem_NEW(PyMemberDef, n_members+1); + if (members == NULL) + return; for (i = 0; i < n_members; ++i) { members[i].name = desc->fields[i].name;