Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when

using byte values greater than 127.  Patch by egreen.
This commit is contained in:
Antoine Pitrou 2009-10-14 17:14:16 +00:00
parent 919765a095
commit 403ce78872
3 changed files with 11 additions and 10 deletions

View file

@ -427,7 +427,7 @@ _Py_bytes_maketrans(PyObject *args)
{
PyObject *frm, *to, *res = NULL;
Py_buffer bfrm, bto;
int i;
Py_ssize_t i;
char *p;
bfrm.len = -1;
@ -452,7 +452,7 @@ _Py_bytes_maketrans(PyObject *args)
for (i = 0; i < 256; i++)
p[i] = i;
for (i = 0; i < bfrm.len; i++) {
p[(int)((char *)bfrm.buf)[i]] = ((char *)bto.buf)[i];
p[((unsigned char *)bfrm.buf)[i]] = ((char *)bto.buf)[i];
}
done: