fix a segv with icc import/export

would segv for very wide images
This commit is contained in:
John Cupitt 2013-05-14 09:38:59 +01:00
parent d6e8abce9b
commit d739a240eb
3 changed files with 26 additions and 17 deletions

View File

@ -1,3 +1,6 @@
14/5/13 started 7.32.4
- icc import and export could segv on very wide images
16/4/13 started 7.32.3
- rename GETTEXT_PACKAGE as vips7.32 to help Debian (thanks Jay)
- added "persistent" option to tilecache

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below
AC_INIT([vips], [7.32.3], [vipsip@jiscmail.ac.uk])
AC_INIT([vips], [7.32.4], [vipsip@jiscmail.ac.uk])
# required for gobject-introspection
AC_PREREQ(2.62)
@ -17,7 +17,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning
m4_define([vips_major_version], [7])
m4_define([vips_minor_version], [32])
m4_define([vips_micro_version], [3])
m4_define([vips_micro_version], [4])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -37,7 +37,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date`
# binary interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=34
LIBRARY_REVISION=1
LIBRARY_REVISION=2
LIBRARY_AGE=3
# patched into include/vips/version.h

View File

@ -22,6 +22,8 @@
* - import and export cast @in to an appropriate format for you
* 25/9/12
* - redo as a class
* 14/5/13
* - import and export would segv on very wide images
*/
/*
@ -458,15 +460,18 @@ vips_icc_import_line( VipsColour *colour,
{
VipsIcc *icc = (VipsIcc *) colour;
VipsPel *p = (VipsPel *) in[0];
float *q = (float *) out;
VipsPel *p;
float *q;
int i;
/* Buffer of encoded 16-bit pixels we transform.
*/
guint16 encoded[3 * PIXEL_BUFFER_SIZE];
while( width > 0 ) {
const int chunk = VIPS_MIN( width, PIXEL_BUFFER_SIZE );
p = (VipsPel *) in[0];
q = (float *) out;
for( i = 0; i < width; i += PIXEL_BUFFER_SIZE ) {
const int chunk = VIPS_MIN( width - i, PIXEL_BUFFER_SIZE );
#ifdef HAVE_LCMS2
cmsDoTransform( icc->trans, p, encoded, chunk );
@ -478,9 +483,8 @@ vips_icc_import_line( VipsColour *colour,
decode_lab( encoded, q, chunk );
p += chunk * VIPS_IMAGE_SIZEOF_PEL( colour->out );
q += chunk * 3;
width -= chunk;
p += PIXEL_BUFFER_SIZE * VIPS_IMAGE_SIZEOF_PEL( colour->in[0] );
q += PIXEL_BUFFER_SIZE * 3;
}
}
@ -635,15 +639,18 @@ vips_icc_export_line( VipsColour *colour,
{
VipsIcc *icc = (VipsIcc *) colour;
float *p = (float *) in[0];
VipsPel *q = (VipsPel *) out;
float *p;
VipsPel *q;
int x;
/* Buffer of encoded 16-bit pixels we transform.
*/
guint16 encoded[3 * PIXEL_BUFFER_SIZE];
while( width > 0 ) {
const int chunk = VIPS_MIN( width, PIXEL_BUFFER_SIZE );
p = (float *) in[0];
q = (VipsPel *) out;
for( x = 0; x < width; x += PIXEL_BUFFER_SIZE ) {
const int chunk = VIPS_MIN( width - x, PIXEL_BUFFER_SIZE );
encode_lab( p, encoded, chunk );
@ -655,9 +662,8 @@ vips_icc_export_line( VipsColour *colour,
g_mutex_unlock( icc->lock );
#endif
p += chunk * 3;
q += chunk * VIPS_IMAGE_SIZEOF_PEL( colour->out );
width -= chunk;
p += PIXEL_BUFFER_SIZE * 3;
q += PIXEL_BUFFER_SIZE * VIPS_IMAGE_SIZEOF_PEL( colour->out );
}
}