diff options
| author | Andrew M. Kuchling <amk@amk.ca> | 2006-10-05 19:08:30 (GMT) |
|---|---|---|
| committer | Andrew M. Kuchling <amk@amk.ca> | 2006-10-05 19:08:30 (GMT) |
| commit | 154a884e6b562dc5b9f04c8a114a7efd12e42723 (patch) | |
| tree | 84d77bd80086e7706c9558cbd0df9097fe10bee1 /Python | |
| parent | 720ea077880294a142e8e0f182b12af0335069e4 (diff) | |
| download | cpython-154a884e6b562dc5b9f04c8a114a7efd12e42723.zip cpython-154a884e6b562dc5b9f04c8a114a7efd12e42723.tar.gz cpython-154a884e6b562dc5b9f04c8a114a7efd12e42723.tar.bz2 | |
[Backport r51221 | neal.norwitz -- the original commit message is wrong;
this code is only used if WITHOUT_COMPLEX is *not* defined, which is the
common case for Python builds.]
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.
Diffstat (limited to 'Python')
| -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 4f4d6b3..ed87f95 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -177,6 +177,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); @@ -184,6 +188,10 @@ w_object(PyObject *v, WFILE *p) w_string(buf, 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); |
