]> granicus.if.org Git - python/commitdiff
This code is actually not used unless WITHOUT_COMPLEX is defined.
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 12 Aug 2006 01:47:59 +0000 (01:47 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 12 Aug 2006 01:47:59 +0000 (01:47 +0000)
However, there was no error checking that PyFloat_FromDouble returned
a valid pointer.  I believe this change is correct as it seemed
to follow other code in the area.

Klocwork # 292.

Python/marshal.c

index 10a6c0c1d7ae1bd11d1328c8cafbffacb2f59f3e..c3bc87f21f04c86d676b14ad55e1c69af003eb2b 100644 (file)
@@ -213,6 +213,10 @@ w_object(PyObject *v, WFILE *p)
                        w_byte(TYPE_COMPLEX, p);
                        temp = (PyFloatObject*)PyFloat_FromDouble(
                                PyComplex_RealAsDouble(v));
+                       if (!temp) {
+                               p->error = 1;
+                               return;
+                       }
                        PyFloat_AsReprString(buf, temp);
                        Py_DECREF(temp);
                        n = strlen(buf);
@@ -220,6 +224,10 @@ w_object(PyObject *v, WFILE *p)
                        w_string(buf, (int)n, p);
                        temp = (PyFloatObject*)PyFloat_FromDouble(
                                PyComplex_ImagAsDouble(v));
+                       if (!temp) {
+                               p->error = 1;
+                               return;
+                       }
                        PyFloat_AsReprString(buf, temp);
                        Py_DECREF(temp);
                        n = strlen(buf);