summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2006-03-07 15:59:09 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2006-03-07 15:59:09 (GMT)
commit361cd4bd6c9c2d56ed154922e016c47d4bee9482 (patch)
tree52d919a372188402f40d1eb5a159a4a233efccff /Modules
parent82735da0165cc8b0b080d7e28d4123c3168c4cf7 (diff)
downloadcpython-361cd4bd6c9c2d56ed154922e016c47d4bee9482.zip
cpython-361cd4bd6c9c2d56ed154922e016c47d4bee9482.tar.gz
cpython-361cd4bd6c9c2d56ed154922e016c47d4bee9482.tar.bz2
Backport r42894: SF #1444030 Fix several potential defects found
by Coverity.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/arraymodule.c11
-rw-r--r--Modules/cStringIO.c1
-rw-r--r--Modules/zipimport.c2
3 files changed, 10 insertions, 4 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 0e78e65..f8c4918 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1826,10 +1826,13 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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 e891114..81b9ac8 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -541,6 +541,7 @@ newOobject(int size) {
UNLESS (self->buf = (char *)malloc(size)) {
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 3a902cd..2dc5048 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -1165,6 +1165,8 @@ initzipimport(void)
mod = Py_InitModule4("zipimport", NULL, zipimport_doc,
NULL, PYTHON_API_VERSION);
+ if (mod == NULL)
+ return;
ZipImportError = PyErr_NewException("zipimport.ZipImportError",
PyExc_ImportError, NULL);