mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 13:14:27 +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
10
_imaging.c
10
_imaging.c
|
@ -1308,14 +1308,18 @@ _putdata(ImagingObject* self, PyObject* args)
|
|||
break;
|
||||
default:
|
||||
for (i = x = y = 0; i < n; i++) {
|
||||
char ink[4];
|
||||
union {
|
||||
char ink[4];
|
||||
INT32 inkint;
|
||||
} u;
|
||||
|
||||
PyObject *op = PySequence_GetItem(data, i);
|
||||
if (!op || !getink(op, image, ink)) {
|
||||
if (!op || !getink(op, image, u.ink)) {
|
||||
Py_DECREF(op);
|
||||
return NULL;
|
||||
}
|
||||
/* FIXME: what about scale and offset? */
|
||||
image->image32[y][x] = *((INT32*) ink);
|
||||
image->image32[y][x] = u.inkint;
|
||||
Py_XDECREF(op);
|
||||
if (++x >= (int) image->xsize)
|
||||
x = 0, y++;
|
||||
|
|
Loading…
Reference in New Issue
Block a user