summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-08-12 01:43:40 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-08-12 01:43:40 (GMT)
commit6f5ff3f3eb7abc2f4750c1319b560f67faf546ac (patch)
tree1b84bed27afcf3a62f50a2a2a6dabe162327866a /Modules
parent2a899c8b767144e809418fd04f83e4e5789084cd (diff)
downloadcpython-6f5ff3f3eb7abc2f4750c1319b560f67faf546ac.zip
cpython-6f5ff3f3eb7abc2f4750c1319b560f67faf546ac.tar.gz
cpython-6f5ff3f3eb7abc2f4750c1319b560f67faf546ac.tar.bz2
Klocwork made another run and found a bunch more problems.
This is the first batch of fixes that should be easy to verify based on context. This fixes problem numbers: 220 (ast), 323-324 (symtable), 321-322 (structseq), 215 (array), 210 (hotshot), 182 (codecs), 209 (etree).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_codecsmodule.c3
-rw-r--r--Modules/_elementtree.c2
-rw-r--r--Modules/_hotshot.c5
-rw-r--r--Modules/arraymodule.c4
4 files changed, 12 insertions, 2 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 405fd7a..4dbceb7 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -192,7 +192,8 @@ escape_encode(PyObject *self,
buf = PyString_AS_STRING (str);
len = PyString_GET_SIZE (str);
memmove(buf, buf+1, len-2);
- _PyString_Resize(&str, len-2);
+ if (_PyString_Resize(&str, len-2) < 0)
+ return NULL;
return codec_tuple(str, PyString_Size(str));
}
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index b468e71..c9e524f 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -809,7 +809,7 @@ element_findtext(ElementObject* self, PyObject* args)
PyObject* text = element_get_text(item);
if (text == Py_None)
return PyString_FromString("");
- Py_INCREF(text);
+ Py_XINCREF(text);
return text;
}
}
diff --git a/Modules/_hotshot.c b/Modules/_hotshot.c
index 6d9776f..21bd383 100644
--- a/Modules/_hotshot.c
+++ b/Modules/_hotshot.c
@@ -313,6 +313,11 @@ unpack_string(LogReaderObject *self, PyObject **pvalue)
return err;
buf = (char *)malloc(len);
+ if (!buf) {
+ PyErr_NoMemory();
+ return ERR_EXCEPTION;
+ }
+
for (i=0; i < len; i++) {
ch = fgetc(self->logfp);
buf[i] = ch;
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index ba154ca..14e5e5d 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -702,6 +702,8 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
/* Special case "a[i:j] = a" -- copy b first */
int ret;
v = array_slice(b, 0, n);
+ if (!v)
+ return -1;
ret = array_ass_slice(a, ilow, ihigh, v);
Py_DECREF(v);
return ret;
@@ -1708,6 +1710,8 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
if (self == av) {
value = array_slice(av, 0, av->ob_size);
av = (arrayobject*)value;
+ if (!av)
+ return -1;
}
else {
Py_INCREF(value);