text autosize could overflow

This commit is contained in:
John Cupitt 2017-09-21 10:39:37 +01:00
parent 64be1d89b5
commit 809f523274

View File

@ -48,8 +48,8 @@
*/ */
/* /*
#define DEBUG
*/ */
#define DEBUG
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
@ -290,14 +290,18 @@ vips_text_autofit( VipsText *text, VipsRect *out_extents )
} }
} }
if( difference > 0 ) { /* If we've hit the target exactly and quit the loop, diff will be 0
text->dpi = lower_dpi; * and we can use upper. Otherwise we are straddling the target and we
*out_extents = lower_extents; * must take lower.
} */
else { if( difference == 0 ) {
text->dpi = upper_dpi; text->dpi = upper_dpi;
*out_extents = upper_extents; *out_extents = upper_extents;
} }
else {
text->dpi = lower_dpi;
*out_extents = lower_extents;
}
return( 0 ); return( 0 );
} }