diff options
author | Georg Brandl <georg@python.org> | 2007-04-21 07:22:57 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-04-21 07:22:57 (GMT) |
commit | 1dfa8ac6f12a9ebffd7839f0b9b97b170b794b89 (patch) | |
tree | b03f9457aac6b9ee4cd320f5bb6cbea14de1461c | |
parent | 9319e43c675920fa69d1461bf9c6bb451647ae4d (diff) | |
download | cpython-1dfa8ac6f12a9ebffd7839f0b9b97b170b794b89.zip cpython-1dfa8ac6f12a9ebffd7839f0b9b97b170b794b89.tar.gz cpython-1dfa8ac6f12a9ebffd7839f0b9b97b170b794b89.tar.bz2 |
Backport r54757 - missing NULL checks.
-rw-r--r-- | Objects/exceptions.c | 2 | ||||
-rw-r--r-- | Objects/longobject.c | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 0cd819c..b73a3f0 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -33,6 +33,8 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyBaseExceptionObject *self; self = (PyBaseExceptionObject *)type->tp_alloc(type, 0); + if (!self) + return NULL; /* the dict is created on the fly in PyObject_GenericSetAttr */ self->message = self->dict = NULL; diff --git a/Objects/longobject.c b/Objects/longobject.c index cb4900d..7bf04d2 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; } |