[Python-checkins] r54902 - python/branches/release25-maint/Objects/exceptions.c python/branches/release25-maint/Objects/longobject.c

georg.brandl python-checkins at python.org
Sat Apr 21 09:22:58 CEST 2007


Author: georg.brandl
Date: Sat Apr 21 09:22:57 2007
New Revision: 54902

Modified:
   python/branches/release25-maint/Objects/exceptions.c
   python/branches/release25-maint/Objects/longobject.c
Log:
Backport r54757 - missing NULL checks.


Modified: python/branches/release25-maint/Objects/exceptions.c
==============================================================================
--- python/branches/release25-maint/Objects/exceptions.c	(original)
+++ python/branches/release25-maint/Objects/exceptions.c	Sat Apr 21 09:22:57 2007
@@ -33,6 +33,8 @@
     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;
 

Modified: python/branches/release25-maint/Objects/longobject.c
==============================================================================
--- python/branches/release25-maint/Objects/longobject.c	(original)
+++ python/branches/release25-maint/Objects/longobject.c	Sat Apr 21 09:22:57 2007
@@ -1739,6 +1739,8 @@
 	     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 @@
 		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 @@
 {
 	if (PyInt_Check(*pw)) {
 		*pw = PyLong_FromLong(PyInt_AS_LONG(*pw));
+		if (*pw == NULL)
+			return -1;
 		Py_INCREF(*pv);
 		return 0;
 	}


More information about the Python-checkins mailing list