mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 09:56:17 +03:00
Merge pull request #1663 from wiredfool/uninitialized-variable
Fixes uninitialized variable warning in _imaging.c:getink
This commit is contained in:
commit
b1f6cecd70
|
@ -879,6 +879,12 @@ class Image(object):
|
|||
trns_im = Image()._new(core.new(self.mode, (1, 1)))
|
||||
if self.mode == 'P':
|
||||
trns_im.putpalette(self.palette)
|
||||
if type(t) == tuple:
|
||||
try:
|
||||
t = trns_im.palette.getcolor(t)
|
||||
except:
|
||||
raise ValueError("Couldn't allocate a palette "+
|
||||
"color for transparency")
|
||||
trns_im.putpixel((0, 0), t)
|
||||
|
||||
if mode in ('L', 'RGB'):
|
||||
|
|
43
_imaging.c
43
_imaging.c
|
@ -471,53 +471,53 @@ getpixel(Imaging im, ImagingAccess access, int x, int y)
|
|||
static char*
|
||||
getink(PyObject* color, Imaging im, char* ink)
|
||||
{
|
||||
int r, g, b, a;
|
||||
double f;
|
||||
int g=0, b=0, a=0;
|
||||
double f=0;
|
||||
/* Windows 64 bit longs are 32 bits, and 0xFFFFFFFF (white) is a
|
||||
python long (not int) that raises an overflow error when trying
|
||||
to return it into a 32 bit C long
|
||||
*/
|
||||
PY_LONG_LONG r = 0;
|
||||
|
||||
/* fill ink buffer (four bytes) with something that can
|
||||
be cast to either UINT8 or INT32 */
|
||||
|
||||
int rIsInt = 1;
|
||||
int rIsInt = 0;
|
||||
if (im->type == IMAGING_TYPE_UINT8 ||
|
||||
im->type == IMAGING_TYPE_INT32 ||
|
||||
im->type == IMAGING_TYPE_SPECIAL) {
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
if (PyLong_Check(color)) {
|
||||
r = (int) PyLong_AsLong(color);
|
||||
r = PyLong_AsLongLong(color);
|
||||
#else
|
||||
if (PyInt_Check(color) || PyLong_Check(color)) {
|
||||
if (PyInt_Check(color))
|
||||
r = PyInt_AS_LONG(color);
|
||||
else
|
||||
r = (int) PyLong_AsLong(color);
|
||||
r = PyLong_AsLongLong(color);
|
||||
#endif
|
||||
rIsInt = 1;
|
||||
}
|
||||
if (r == -1 && PyErr_Occurred())
|
||||
if (r == -1 && PyErr_Occurred()) {
|
||||
rIsInt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
switch (im->type) {
|
||||
case IMAGING_TYPE_UINT8:
|
||||
/* unsigned integer */
|
||||
if (im->bands == 1) {
|
||||
/* unsigned integer, single layer */
|
||||
if (rIsInt != 1)
|
||||
if (rIsInt != 1) {
|
||||
if (!PyArg_ParseTuple(color, "i", &r)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
ink[0] = CLIP(r);
|
||||
ink[1] = ink[2] = ink[3] = 0;
|
||||
} else {
|
||||
a = 255;
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
if (PyLong_Check(color)) {
|
||||
r = (int) PyLong_AsLong(color);
|
||||
#else
|
||||
if (PyInt_Check(color) || PyLong_Check(color)) {
|
||||
if (PyInt_Check(color))
|
||||
r = PyInt_AS_LONG(color);
|
||||
else
|
||||
r = (int) PyLong_AsLong(color);
|
||||
#endif
|
||||
|
||||
if (rIsInt) {
|
||||
/* compatibility: ABGR */
|
||||
a = (UINT8) (r >> 24);
|
||||
b = (UINT8) (r >> 16);
|
||||
|
@ -590,13 +590,14 @@ _fill(PyObject* self, PyObject* args)
|
|||
if (!im)
|
||||
return NULL;
|
||||
|
||||
buffer[0] = buffer[1] = buffer[2] = buffer[3] = 0;
|
||||
if (color) {
|
||||
if (!getink(color, im, buffer)) {
|
||||
ImagingDelete(im);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
buffer[0] = buffer[1] = buffer[2] = buffer[3] = 0;
|
||||
}
|
||||
|
||||
|
||||
(void) ImagingFill(im, buffer);
|
||||
|
||||
|
@ -1342,6 +1343,8 @@ _putdata(ImagingObject* self, PyObject* args)
|
|||
INT32 inkint;
|
||||
} u;
|
||||
|
||||
u.inkint = 0;
|
||||
|
||||
op = PySequence_Fast_GET_ITEM(seq, i);
|
||||
if (!op || !getink(op, image, u.ink)) {
|
||||
Py_DECREF(seq);
|
||||
|
|
Loading…
Reference in New Issue
Block a user