Do not precompute horizontal coefficients if not horizontal resizing (#9543)

This commit is contained in:
Hugo van Kemenade 2026-04-06 20:29:12 +03:00 committed by GitHub
commit c722aaec53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -726,19 +726,10 @@ ImagingResampleInner(
need_horizontal = xsize != imIn->xsize || box[0] || box[2] != xsize;
need_vertical = ysize != imIn->ysize || box[1] || box[3] != ysize;
ksize_horiz = precompute_coeffs(
imIn->xsize, box[0], box[2], xsize, filterp, &bounds_horiz, &kk_horiz
);
if (!ksize_horiz) {
return NULL;
}
ksize_vert = precompute_coeffs(
imIn->ysize, box[1], box[3], ysize, filterp, &bounds_vert, &kk_vert
);
if (!ksize_vert) {
free(bounds_horiz);
free(kk_horiz);
return NULL;
}
@ -749,6 +740,15 @@ ImagingResampleInner(
/* two-pass resize, horizontal pass */
if (need_horizontal) {
ksize_horiz = precompute_coeffs(
imIn->xsize, box[0], box[2], xsize, filterp, &bounds_horiz, &kk_horiz
);
if (!ksize_horiz) {
free(bounds_vert);
free(kk_vert);
return NULL;
}
// Shift bounds for vertical pass
for (i = 0; i < ysize; i++) {
bounds_vert[i * 2] -= ybox_first;
@ -768,10 +768,6 @@ ImagingResampleInner(
return NULL;
}
imOut = imIn = imTemp;
} else {
// Free in any case
free(bounds_horiz);
free(kk_horiz);
}
/* vertical pass */