diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-08-12 01:47:59 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-08-12 01:47:59 (GMT) |
commit | edb216807948670f716f920d3f7c6c0df3422381 (patch) | |
tree | 679eee2c0acf8239635aba1341931fa697a66dd7 | |
parent | 43bd4db933711da450931824add443549a757455 (diff) | |
download | cpython-edb216807948670f716f920d3f7c6c0df3422381.zip cpython-edb216807948670f716f920d3f7c6c0df3422381.tar.gz cpython-edb216807948670f716f920d3f7c6c0df3422381.tar.bz2 |
This code is actually not used unless WITHOUT_COMPLEX is defined.
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.
-rw-r--r-- | Python/marshal.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/marshal.c b/Python/marshal.c index 10a6c0c..c3bc87f 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -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); |