changeset 16848:19a915d43a68

base85: cast Py_ssize_t values to int (issue3481) If it outputs a nonsense value, no harm done, it was nonsense to start with.
author Adrian Buehlmann <adrian@cadifra.com>
date Mon, 04 Jun 2012 16:59:34 +0200
parents cda5402b1739
children 928ee57e3aae
files mercurial/base85.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/base85.c	Mon Jun 04 19:05:22 2012 +0200
+++ b/mercurial/base85.c	Mon Jun 04 16:59:34 2012 +0200
@@ -111,7 +111,8 @@
 			if (c < 0)
 				return PyErr_Format(
 					PyExc_ValueError,
-					"bad base85 character at position %d", i);
+					"bad base85 character at position %d",
+					(int)i);
 			acc = acc * 85 + c;
 		}
 		if (i++ < len)
@@ -120,13 +121,15 @@
 			if (c < 0)
 				return PyErr_Format(
 					PyExc_ValueError,
-					"bad base85 character at position %d", i);
+					"bad base85 character at position %d",
+					(int)i);
 			/* overflow detection: 0xffffffff == "|NsC0",
 			 * "|NsC" == 0x03030303 */
 			if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c)
 				return PyErr_Format(
 					PyExc_ValueError,
-					"bad base85 sequence at position %d", i);
+					"bad base85 sequence at position %d",
+					(int)i);
 			acc += c;
 		}