Skip to content

Commit

Permalink
Bug 1530222 - Allow libpng to allocate larger chunks for decoding pur…
Browse files Browse the repository at this point in the history
…poses. r=tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D21533
  • Loading branch information
aosmond committed Mar 1, 2019
1 parent cf64822 commit b4b0a26
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions image/decoders/nsPNGDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ static LazyLogModule sPNGDecoderAccountingLog("PNGDecoderAccounting");
# define MOZ_PNG_MAX_HEIGHT 0x7fffffff // Unlimited
#endif

/* Controls the maximum chunk size configuration for libpng. We set this to a
* very large number, 256MB specifically. */
static constexpr png_alloc_size_t kPngMaxChunkSize = 0x10000000;

nsPNGDecoder::AnimFrameInfo::AnimFrameInfo()
: mDispose(DisposalMethod::KEEP), mBlend(BlendMethod::OVER), mTimeout(0) {}

Expand Down Expand Up @@ -312,9 +316,7 @@ nsresult nsPNGDecoder::InitInternal() {

#ifdef PNG_SET_USER_LIMITS_SUPPORTED
png_set_user_limits(mPNG, MOZ_PNG_MAX_WIDTH, MOZ_PNG_MAX_HEIGHT);
if (mCMSMode != eCMSMode_Off) {
png_set_chunk_malloc_max(mPNG, 4000000L);
}
png_set_chunk_malloc_max(mPNG, kPngMaxChunkSize);
#endif

#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
Expand Down

0 comments on commit b4b0a26

Please sign in to comment.