reducev: Fix undefined-behaviour within the vector path

Found by UBSan.
This commit is contained in:
Kleis Auke Wolthuizen 2020-06-06 14:50:32 +02:00
parent ac30bad695
commit d7a735400a
2 changed files with 4 additions and 6 deletions

View File

@ -653,10 +653,9 @@ vips_reducev_vector_gen( VipsRegion *out_region, void *vseq,
#endif /*DEBUG_PIXELS*/
s.left = r->left;
s.top = r->top * reducev->vshrink;
s.top = r->top * reducev->vshrink - reducev->voffset;
s.width = r->width;
s.height = r->height * reducev->vshrink + reducev->n_point -
reducev->voffset;
s.height = r->height * reducev->vshrink + reducev->n_point;
if( vips_region_prepare( ir, &s ) )
return( -1 );

View File

@ -82,9 +82,8 @@ class TestResample:
for fac in [1, 1.1, 1.5, 1.999]:
for fmt in all_formats:
# TODO: Add nearest kernel when https://github.com/libvips/libvips/issues/1518 is done.
# (running the test suite with VIPS_NOVECTOR=1 should also work)
for kernel in ["linear", "cubic", "lanczos2", "lanczos3"]:
for kernel in ["nearest", "linear",
"cubic", "lanczos2", "lanczos3"]:
x = im.cast(fmt)
r = x.reduce(fac, fac, kernel=kernel)
d = abs(r.avg() - im.avg())