mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-16 04:16:35 +03:00
set error type when it happens
This commit is contained in:
parent
8d7355e733
commit
c7161af924
|
@ -146,19 +146,24 @@ precompute_coeffs(int inSize, float in0, float in1, int outSize,
|
||||||
kmax = (int) ceil(support) * 2 + 1;
|
kmax = (int) ceil(support) * 2 + 1;
|
||||||
|
|
||||||
// check for overflow
|
// check for overflow
|
||||||
if (outSize > INT_MAX / (kmax * sizeof(double)))
|
if (outSize > INT_MAX / (kmax * sizeof(double))) {
|
||||||
|
ImagingError_MemoryError();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* coefficient buffer */
|
/* coefficient buffer */
|
||||||
/* malloc check ok, overflow checked above */
|
/* malloc check ok, overflow checked above */
|
||||||
kk = malloc(outSize * kmax * sizeof(double));
|
kk = malloc(outSize * kmax * sizeof(double));
|
||||||
if ( ! kk)
|
if ( ! kk) {
|
||||||
|
ImagingError_MemoryError();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* malloc check ok, kmax*sizeof(double) > 2*sizeof(int) */
|
/* malloc check ok, kmax*sizeof(double) > 2*sizeof(int) */
|
||||||
xbounds = malloc(outSize * 2 * sizeof(int));
|
xbounds = malloc(outSize * 2 * sizeof(int));
|
||||||
if ( ! xbounds) {
|
if ( ! xbounds) {
|
||||||
free(kk);
|
free(kk);
|
||||||
|
ImagingError_MemoryError();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +576,7 @@ ImagingResampleInner(Imaging imIn, int xsize, int ysize,
|
||||||
kmax = precompute_coeffs(imIn->xsize, box[0], box[2], xsize, filterp,
|
kmax = precompute_coeffs(imIn->xsize, box[0], box[2], xsize, filterp,
|
||||||
&xbounds, &kk);
|
&xbounds, &kk);
|
||||||
if ( ! kmax) {
|
if ( ! kmax) {
|
||||||
return (Imaging) ImagingError_MemoryError();
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
imTemp = ImagingNew(imIn->mode, xsize, imIn->ysize);
|
imTemp = ImagingNew(imIn->mode, xsize, imIn->ysize);
|
||||||
|
@ -592,7 +597,7 @@ ImagingResampleInner(Imaging imIn, int xsize, int ysize,
|
||||||
&xbounds, &kk);
|
&xbounds, &kk);
|
||||||
if ( ! kmax) {
|
if ( ! kmax) {
|
||||||
ImagingDelete(imTemp);
|
ImagingDelete(imTemp);
|
||||||
return (Imaging) ImagingError_MemoryError();
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
imOut = ImagingNew(imIn->mode, imIn->xsize, ysize);
|
imOut = ImagingNew(imIn->mode, imIn->xsize, ysize);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user