SF #1444030: Fix several potential defects found by Coverity.
(reviewed by Neal Norwitz)
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index be12775..2318739 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1852,10 +1852,13 @@
Py_DECREF(v);
}
} else if (initial != NULL && PyString_Check(initial)) {
- PyObject *t_initial = PyTuple_Pack(1,
- initial);
- PyObject *v =
- array_fromstring((arrayobject *)a,
+ PyObject *t_initial, *v;
+ t_initial = PyTuple_Pack(1, initial);
+ if (t_initial == NULL) {
+ Py_DECREF(a);
+ return NULL;
+ }
+ v = array_fromstring((arrayobject *)a,
t_initial);
Py_DECREF(t_initial);
if (v == NULL) {
diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c
index 14e35f3..fd28aa9 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -544,6 +544,7 @@
if (!self->buf) {
PyErr_SetString(PyExc_MemoryError,"out of memory");
self->buf_size = 0;
+ Py_DECREF(self);
return NULL;
}
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index fa4380c..637dc48 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -1167,6 +1167,8 @@
mod = Py_InitModule4("zipimport", NULL, zipimport_doc,
NULL, PYTHON_API_VERSION);
+ if (mod == NULL)
+ return;
ZipImportError = PyErr_NewException("zipimport.ZipImportError",
PyExc_ImportError, NULL);