diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2006-10-09 18:42:49 +0000 |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2006-10-09 18:42:49 +0000 |
commit | 2fafa251dba5df1f90326a825ac6de2b6b906bc3 (patch) | |
tree | d99394a027e246095bb69b4a83595cf11fd42d43 | |
parent | cebdc5e373e9df417b24e4f5442637f27d53f4ba (diff) | |
download | cpython-git-2fafa251dba5df1f90326a825ac6de2b6b906bc3.tar.gz |
[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]
-rw-r--r-- | Objects/longobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 5847feb87b..97becdb5a4 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1468,9 +1468,10 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem) 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; |