diff Objects/structseq.c @ 27608:beb2008a3c32 2.2

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.
author Neal Norwitz <nnorwitz@gmail.com>
date Sun, 02 Feb 2003 19:25:22 +0000
parents 68831ac5495b
children
line wrap: on
line diff
--- a/Objects/structseq.c	Sun Feb 02 19:24:38 2003 +0000
+++ b/Objects/structseq.c	Sun Feb 02 19:25:22 2003 +0000
@@ -140,6 +140,9 @@
 	}
 
 	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 @@
 	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;