]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Partial backport of r51218 | neal.norwitz -- the changes to ast.c, symtable.c,
authorAndrew M. Kuchling <amk@amk.ca>
Thu, 5 Oct 2006 18:37:08 +0000 (18:37 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Thu, 5 Oct 2006 18:37:08 +0000 (18:37 +0000)
 and _elementtree.c weren't applicable]

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).

Modules/_codecsmodule.c
Modules/arraymodule.c
Objects/structseq.c

index 3441f6195856ebab14636bd73d3f0e70149fdf8e..eef63a76be844255fc8fc803b03816adb816d4b2 100644 (file)
@@ -226,7 +226,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));
 }
index 593fc48995467ca85211d9312e0fa58a6e0a31c2..d8b1eaab817e2522721342cc3d4d05b22784cfbd 100644 (file)
@@ -701,6 +701,8 @@ array_ass_slice(arrayobject *a, int ilow, int 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;
@@ -1687,6 +1689,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);
index 603477f594e87e9e5933ca4204cef15eda4a24fe..d0476f6b03a3b476145e9b3a59689f3d8d63f206 100644 (file)
@@ -215,6 +215,8 @@ structseq_contains(PyStructSequence *obj, PyObject *o)
        PyObject *tup;
        int result;
        tup = make_tuple(obj);
+       if (!tup)
+               return -1;
        result = PySequence_Contains(tup, o);
        Py_DECREF(tup);
        return result;
@@ -226,6 +228,8 @@ structseq_hash(PyObject *obj)
        PyObject *tup;
        long result;
        tup = make_tuple((PyStructSequence*) obj);
+       if (!tup)
+               return -1;
        result = PyObject_Hash(tup);
        Py_DECREF(tup);
        return result;