Skip to content

Commit e88e5f0

Browse files
authored
text: simplify check for 32k pixel limit (#3057)
1 parent fa4b80b commit e88e5f0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

libvips/create/text.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ vips_text_build( VipsObject *object )
348348
VipsImage *image;
349349
cairo_surface_t *surface;
350350
cairo_t *cr;
351+
cairo_status_t status;
351352

352353
if( VIPS_OBJECT_CLASS( vips_text_parent_class )->build( object ) )
353354
return( -1 );
@@ -417,15 +418,6 @@ vips_text_build( VipsObject *object )
417418
return( -1 );
418419
}
419420

420-
/* Cairo can't go over 32k pixels.
421-
*/
422-
if( extents.width >= 32768 ||
423-
extents.height >= 32768 ) {
424-
vips_error( class->nickname,
425-
"%s", _( "text image too large" ) );
426-
return( -1 );
427-
}
428-
429421
image = t[0] = vips_image_new_memory();
430422
vips_image_init_fields( image,
431423
extents.width, extents.height, 4,
@@ -444,6 +436,15 @@ vips_text_build( VipsObject *object )
444436
CAIRO_FORMAT_ARGB32,
445437
image->Xsize, image->Ysize,
446438
VIPS_IMAGE_SIZEOF_LINE( image ) );
439+
440+
status = cairo_surface_status( surface );
441+
if( status ) {
442+
cairo_surface_destroy( surface );
443+
vips_error( class->nickname,
444+
"%s", cairo_status_to_string( status ) );
445+
return( -1 );
446+
}
447+
447448
cr = cairo_create( surface );
448449
cairo_surface_destroy( surface );
449450

0 commit comments

Comments
 (0)