]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport:
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 2 Feb 2003 19:25:22 +0000 (19:25 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 2 Feb 2003 19:25:22 +0000 (19:25 +0000)
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.

Objects/structseq.c

index 377dfebd2ed5599ba78cdc24381b57e8c4ecf601..26cd5eef0dc7dea54a476833fa68f2c63a6f9b43 100644 (file)
@@ -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;