diff options
author | Georg Brandl <georg@python.org> | 2007-04-11 17:16:24 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-04-11 17:16:24 +0000 |
commit | c02e13122ba94b05dc03fd56de393b9129f3ed25 (patch) | |
tree | 1928b2cb6377a200b57505ce08d6e0ff3135985f /Objects/longobject.c | |
parent | 5bf02cd17f96217cbdffd84e3b00bf5c97acf69e (diff) | |
download | cpython-git-c02e13122ba94b05dc03fd56de393b9129f3ed25.tar.gz |
Add some missing NULL checks which trigger crashes on low-memory conditions.
Found by Victor Stinner. Will backport when 2.5 branch is unfrozen.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 6b8d6e4b40..6d55354bf6 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1739,6 +1739,8 @@ long_divrem(PyLongObject *a, PyLongObject *b, a->ob_digit[size_a-1] < b->ob_digit[size_b-1])) { /* |a| < |b|. */ *pdiv = _PyLong_New(0); + if (*pdiv == NULL) + return -1; Py_INCREF(a); *prem = (PyLongObject *) a; return 0; @@ -1749,6 +1751,10 @@ long_divrem(PyLongObject *a, PyLongObject *b, if (z == NULL) return -1; *prem = (PyLongObject *) PyLong_FromLong((long)rem); + if (*prem == NULL) { + Py_DECREF(z); + return -1; + } } else { z = x_divrem(a, b, prem); @@ -3204,6 +3210,8 @@ long_coerce(PyObject **pv, PyObject **pw) { if (PyInt_Check(*pw)) { *pw = PyLong_FromLong(PyInt_AS_LONG(*pw)); + if (*pw == NULL) + return -1; Py_INCREF(*pv); return 0; } |