Bug 1315863 - Use PNG_MAXIMUM_INFLATE_WINDOW to ensure maximum compatibility with existing images. r=glennrp

This commit is contained in:
Andrew Osmond 2016-11-16 15:21:33 -05:00
parent b1bbb27d76
commit f944648035
2 changed files with 11 additions and 2 deletions

View File

@ -340,12 +340,20 @@ nsPNGDecoder::InitInternal()
png_set_check_for_invalid_index(mPNG, 0);
#endif
#if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_sRGB_PROFILE_CHECKS) && \
PNG_sRGB_PROFILE_CHECKS >= 0
#ifdef PNG_SET_OPTION_SUPPORTED
#if defined(PNG_sRGB_PROFILE_CHECKS) && PNG_sRGB_PROFILE_CHECKS >= 0
// Skip checking of sRGB ICC profiles
png_set_option(mPNG, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON);
#endif
#ifdef PNG_MAXIMUM_INFLATE_WINDOW
// Force a larger zlib inflate window as some images in the wild have
// incorrectly set metadata (specifically CMF bits) which prevent us from
// decoding them otherwise.
png_set_option(mPNG, PNG_MAXIMUM_INFLATE_WINDOW, PNG_OPTION_ON);
#endif
#endif
// use this as libpng "progressive pointer" (retrieve in callbacks)
png_set_progressive_read_fn(mPNG, static_cast<png_voidp>(this),
nsPNGDecoder::info_callback,

View File

@ -25,6 +25,7 @@
#define PNG_LINKAGE_DATA extern
#define PNG_LINKAGE_FUNCTION extern
#define PNG_MAX_GAMMA_8 11
#define PNG_SET_OPTION_SUPPORTED
#define PNG_sRGB_PROFILE_CHECKS -1
#define PNG_USER_CHUNK_CACHE_MAX 128
#define PNG_USER_CHUNK_MALLOC_MAX 4000000L