[Python-checkins] r52249 - python/branches/release24-maint/Objects/longobject.c

andrew.kuchling python-checkins at python.org
Mon Oct 9 20:42:49 CEST 2006


Author: andrew.kuchling
Date: Mon Oct  9 20:42:49 2006
New Revision: 52249

Modified:
   python/branches/release24-maint/Objects/longobject.c
Log:
[Partial backport of r45947 | neal.norwitz]

Fix problems found by Coverity.

longobject.c: also fix an ssize_t problem
  <a> could have been NULL, so hoist the size calc to not use <a>.

[The ssize_t change isn't needed for 2.4.  The other changes in this revision
 are to modules not present in 2.4. --amk]


Modified: python/branches/release24-maint/Objects/longobject.c
==============================================================================
--- python/branches/release24-maint/Objects/longobject.c	(original)
+++ python/branches/release24-maint/Objects/longobject.c	Mon Oct  9 20:42:49 2006
@@ -1468,9 +1468,10 @@
 	assert(size_w == ABS(w->ob_size)); /* That's how d was calculated */
 
 	size_v = ABS(v->ob_size);
-	a = _PyLong_New(size_v - size_w + 1);
+	k = size_v - size_w;
+	a = _PyLong_New(k + 1);
 
-	for (j = size_v, k = a->ob_size-1; a != NULL && k >= 0; --j, --k) {
+	for (j = size_v; a != NULL && k >= 0; --j, --k) {
 		digit vj = (j >= size_v) ? 0 : v->ob_digit[j];
 		twodigits q;
 		stwodigits carry = 0;


More information about the Python-checkins mailing list