mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-27 05:24:12 +03:00
Fixed comparison between int and unsigned long
This commit is contained in:
parent
d0c685fbfa
commit
26e5929617
|
@ -3928,7 +3928,7 @@ _set_blocks_max(PyObject* self, PyObject* args)
|
|||
"blocks_max should be greater than 0");
|
||||
return NULL;
|
||||
}
|
||||
else if ( blocks_max > SIZE_MAX/sizeof(ImagingDefaultArena.blocks_pool[0])) {
|
||||
else if ( (unsigned long)blocks_max > SIZE_MAX/sizeof(ImagingDefaultArena.blocks_pool[0])) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"blocks_max is too large");
|
||||
return NULL;
|
||||
|
|
|
@ -1630,7 +1630,7 @@ allocate(ImagingOutline outline, int extra)
|
|||
/* malloc check ok, uses calloc for overflow */
|
||||
e = calloc(outline->size, sizeof(Edge));
|
||||
} else {
|
||||
if (outline->size > INT_MAX / sizeof(Edge)) {
|
||||
if (outline->size > INT_MAX / (int)sizeof(Edge)) {
|
||||
return NULL;
|
||||
}
|
||||
/* malloc check ok, overflow checked above */
|
||||
|
|
|
@ -72,7 +72,7 @@ ImagingRankFilter(Imaging im, int size, int rank)
|
|||
|
||||
/* malloc check ok, for overflow in the define below */
|
||||
if (size > INT_MAX / size ||
|
||||
size > INT_MAX / (size * sizeof(FLOAT32))) {
|
||||
size > INT_MAX / (size * (int)sizeof(FLOAT32))) {
|
||||
return (Imaging) ImagingError_ValueError("filter size too large");
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ precompute_coeffs(int inSize, float in0, float in1, int outSize,
|
|||
ksize = (int) ceil(support) * 2 + 1;
|
||||
|
||||
// check for overflow
|
||||
if (outSize > INT_MAX / (ksize * sizeof(double))) {
|
||||
if (outSize > INT_MAX / (ksize * (int)sizeof(double))) {
|
||||
ImagingError_MemoryError();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user