From e233698c2b72b963e79d72186c845ea2b8c13f7f Mon Sep 17 00:00:00 2001 From: Matt Drollette Date: Tue, 10 Sep 2019 12:31:11 -0500 Subject: [PATCH] also set png max chunk malloc when reading buffer --- libvips/foreign/vipspng.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index c1508a5c..9d87cc93 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -812,7 +812,13 @@ read_new_buffer( VipsImage *out, const void *buffer, size_t length, /* Read enough of the file that png_get_interlace_type() will start * working. + * + * By default, libpng refuses to open files with a metadata chunk + * larger than 8mb. We've seen real files with 20mb, so set 50mb. */ +#ifdef HAVE_PNG_SET_CHUNK_MALLOC_MAX + png_set_chunk_malloc_max( read->pPng, 50 * 1024 * 1024 ); +#endif /*HAVE_PNG_SET_CHUNK_MALLOC_MAX*/ png_read_info( read->pPng, read->pInfo ); return( read );