remove 256 band limit from arithmetic.c

there was a fixed-size array in vips__bandup()

see https://github.com/libvips/libvips/issues/1335
This commit is contained in:
John Cupitt 2019-06-12 09:22:30 +01:00
parent ad98222073
commit 37a3a6322c
2 changed files with 10 additions and 3 deletions

View File

@ -8,6 +8,7 @@
magic number [przemyslawpluta]
- much faster ismagick() [jcupitt]
- better behaviour for vips_region_fetch() if request lies partly ouside image
- remove band limits [erdmann]
21/9/18 started 8.8.0
- much faster smartcrop [lovell]

View File

@ -369,8 +369,9 @@ vips__sizealike_vec( VipsImage **in, VipsImage **out, int n )
int
vips__bandup( const char *domain, VipsImage *in, VipsImage **out, int n )
{
VipsImage *bands[256];
VipsImage **bands;
int i;
int result;
if( in->Bands == n )
return( vips_copy( in, out, NULL ) );
@ -378,15 +379,20 @@ vips__bandup( const char *domain, VipsImage *in, VipsImage **out, int n )
vips_error( domain, _( "not one band or %d bands" ), n );
return( -1 );
}
if( n > 256 || n < 1 ) {
if( n > VIPS_MAX_COORD ||
n < 1 ) {
vips_error( domain, "%s", _( "bad bands" ) );
return( -1 );
}
if( !(bands = VIPS_ARRAY( NULL, n, VipsImage * )) )
return( -1 );
for( i = 0; i < n; i++ )
bands[i] = in;
result = vips_bandjoin( bands, out, n, NULL );
VIPS_FREE( bands );
return( vips_bandjoin( bands, out, n, NULL ) );
return( result );
}
/* base_bands is the default minimum.