From: Mark Wooding Date: Fri, 3 Jun 2016 20:27:36 +0000 (+0100) Subject: bytestring.c: Use `Py_ssize_t' for collecting buffer lengths. X-Git-Tag: 1.1.1~1 X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/commitdiff_plain/87d705a84eddb339613261871603b272329fe979 bytestring.c: Use `Py_ssize_t' for collecting buffer lengths. On 64-bit platforms, this is a 64-bit long, so if we pass an int to `PyObject_AsReadBuffer', it will clobber the next word too. --- diff --git a/bytestring.c b/bytestring.c index 99c114c..b3b32de 100644 --- a/bytestring.c +++ b/bytestring.c @@ -66,7 +66,7 @@ static PyObject *bytestring_pynew(PyTypeObject *ty, const void *xv, *yv; \ const unsigned char *xp, *yp; \ unsigned char *zp; \ - int xsz, ysz; \ + Py_ssize_t xsz, ysz; \ int i; \ PyObject *rc = 0; \ if (PyObject_AsReadBuffer(x, &xv, &xsz) || \ @@ -88,7 +88,7 @@ BINOP(xor, ^) const void *xv; \ const unsigned char *xp; \ unsigned char *zp; \ - int xsz; \ + Py_ssize_t xsz; \ int i; \ PyObject *rc = 0; \ if (PyObject_AsReadBuffer(x, &xv, &xsz)) goto end; \