mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 17:33:08 +03:00
py3k: Fix strict aliasing slip-up in _imaging
Python 3 enables C's strict aliasing rules for the first time, which means you need to be careful about the ways you reference pointers. Here, we're using a char[4] as an INT32, so we cast between them using a union.
This commit is contained in:
parent
d28a2fee76
commit
89e82c5888
|
@ -1308,14 +1308,18 @@ _putdata(ImagingObject* self, PyObject* args)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
for (i = x = y = 0; i < n; i++) {
|
for (i = x = y = 0; i < n; i++) {
|
||||||
|
union {
|
||||||
char ink[4];
|
char ink[4];
|
||||||
|
INT32 inkint;
|
||||||
|
} u;
|
||||||
|
|
||||||
PyObject *op = PySequence_GetItem(data, i);
|
PyObject *op = PySequence_GetItem(data, i);
|
||||||
if (!op || !getink(op, image, ink)) {
|
if (!op || !getink(op, image, u.ink)) {
|
||||||
Py_DECREF(op);
|
Py_DECREF(op);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* FIXME: what about scale and offset? */
|
/* FIXME: what about scale and offset? */
|
||||||
image->image32[y][x] = *((INT32*) ink);
|
image->image32[y][x] = u.inkint;
|
||||||
Py_XDECREF(op);
|
Py_XDECREF(op);
|
||||||
if (++x >= (int) image->xsize)
|
if (++x >= (int) image->xsize)
|
||||||
x = 0, y++;
|
x = 0, y++;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user