]> granicus.if.org Git - python/commitdiff
Backport r54757 - missing NULL checks.
authorGeorg Brandl <georg@python.org>
Sat, 21 Apr 2007 07:22:57 +0000 (07:22 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 21 Apr 2007 07:22:57 +0000 (07:22 +0000)
Objects/exceptions.c
Objects/longobject.c

index 0cd819c5a1559396d9aa43ce64615d22578fffbc..b73a3f0b7e10aa586be397d929184ce1f8edcb25 100644 (file)
@@ -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;
 
index cb4900d9d036f2b0a1465fe9ace000e37249169a..7bf04d294154ad13315c95304db1b7139559230c 100644 (file)
@@ -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;
        }