[Zope-CVS] CVS: Packages/Spread - spreadmodule.c:1.6

Guido van Rossum guido@python.org
Wed, 19 Dec 2001 17:58:34 -0500


Update of /cvs-repository/Packages/Spread
In directory cvs.zope.org:/tmp/cvs-serv32699

Modified Files:
	spreadmodule.c 
Log Message:
Add error checking to all _PyString_Resize() calls.


=== Packages/Spread/spreadmodule.c 1.5 => 1.6 ===
 	    return NULL;
 	}
-	_PyString_Resize(&s, strlen(PyString_AS_STRING(s)));
+	if (_PyString_Resize(&s, strlen(PyString_AS_STRING(s))) < 0) {
+	    Py_DECREF(self->extra);
+	    return NULL;
+	}
 	PyTuple_SET_ITEM(self->extra, i, s);
     }
     return self;
@@ -465,7 +468,8 @@
 
     if (svc_type & REG_MEMB_MESS) {
 	assert(endian == 0);
-	_PyString_Resize(&sender, strlen(PyString_AS_STRING(sender)));
+	if (_PyString_Resize(&sender, strlen(PyString_AS_STRING(sender))) < 0)
+	    goto error;
 	msg = (PyObject *)new_membership_msg(svc_type, sender,
 					     num_groups, groups, 
 					     PyString_AS_STRING(message)); 
@@ -474,13 +478,16 @@
 			"can't handle transitional messages yet");
 	goto error;
     } else if (svc_type & REGULAR_MESS) {
-	_PyString_Resize(&sender, strlen(PyString_AS_STRING(sender)));
-	_PyString_Resize(&message, size);
+        if (_PyString_Resize(&sender, strlen(PyString_AS_STRING(sender))) < 0)
+	    goto error;
+	if (_PyString_Resize(&message, size) < 0)
+	    goto error;
 	msg = (PyObject *)new_regular_msg(sender, num_groups, groups,
 					  msg_type, endian, message, size);
     } else if (svc_type & MEMBERSHIP_MESS) {
 	assert(svc_type & CAUSED_BY_LEAVE);
-	_PyString_Resize(&sender, strlen(PyString_AS_STRING(sender)));
+	if (_PyString_Resize(&sender, strlen(PyString_AS_STRING(sender))) < 0)
+	    goto error;
 	msg = (PyObject *)new_membership_msg(svc_type, sender,
 					     num_groups, groups, 
 					     PyString_AS_STRING(message)); 
@@ -654,7 +661,12 @@
 	    SP_disconnect(_mbox);
 	    return NULL;
 	}
-	_PyString_Resize(&group_name, strlen(PyString_AS_STRING(group_name)));
+	if (_PyString_Resize(&group_name,
+			     strlen(PyString_AS_STRING(group_name))) < 0) {
+	    SP_disconnect(_mbox);
+	    Py_DECREF(mbox);
+	    return NULL;
+	}
 	mbox->private_group = group_name;
 	return (PyObject*)mbox;
     }