summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-05-10 06:57:58 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-05-10 06:57:58 (GMT)
commitc6a989ac3a2ce1f52f48acfb73d04b604ba173b1 (patch)
treebce50037904969634cf2ed60d969829dd0283f95 /Objects/longobject.c
parentad2ef33245bdd90bf0e80824dbba732b17fdf6b6 (diff)
downloadcpython-c6a989ac3a2ce1f52f48acfb73d04b604ba173b1.zip
cpython-c6a989ac3a2ce1f52f48acfb73d04b604ba173b1.tar.gz
cpython-c6a989ac3a2ce1f52f48acfb73d04b604ba173b1.tar.bz2
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>. _ssl.c: under fail: self is DECREF'd, but it would have been NULL. _elementtree.c: delete self if there was an error. _csv.c: I'm not sure if lineterminator could have been anything other than a string. However, other string method calls are checked, so check this one too.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 5ac570d..e04699e 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -66,8 +66,7 @@ long_normalize(register PyLongObject *v)
PyLongObject *
_PyLong_New(Py_ssize_t size)
{
- if (size > INT_MAX) {
- /* XXX: Fix this check when ob_size becomes ssize_t */
+ if (size > PY_SSIZE_T_MAX) {
PyErr_NoMemory();
return NULL;
}
@@ -1580,9 +1579,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;