From 8dca0247d20cecb7e88d075026a07e6427d2cab6 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Fri, 1 Apr 2016 00:59:39 -0700 Subject: [PATCH] fix bug in alpha.c that was triggering a memory error in incremental mode this change will be superseded by patch #335160 eventually, but until then let's fix the problem temporarily. Change-Id: Iafd979c2ff6801e3f1de4614870ca854a4747b04 --- src/dec/alpha.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/dec/alpha.c b/src/dec/alpha.c index 7f90ddca..47c70395 100644 --- a/src/dec/alpha.c +++ b/src/dec/alpha.c @@ -131,30 +131,31 @@ const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, return NULL; // sanity check. } - if (dec->alph_dec_ == NULL) { // Initialize decoder. - assert(dec->alpha_plane_ != NULL); - dec->alph_dec_ = ALPHNew(); - if (dec->alph_dec_ == NULL) return NULL; - if (!ALPHInit(dec->alph_dec_, dec->alpha_data_, dec->alpha_data_size_, - io->width, io->height, dec->alpha_plane_)) { - ALPHDelete(dec->alph_dec_); - dec->alph_dec_ = NULL; - return NULL; - } - // if we allowed use of alpha dithering, check whether it's needed at all - if (dec->alph_dec_->pre_processing_ != ALPHA_PREPROCESSED_LEVELS) { - dec->alpha_dithering_ = 0; // disable dithering - } else { - num_rows = height; // decode everything in one pass - } - } - - if (row + num_rows > height) { - num_rows = height - row; - } - if (!dec->is_alpha_decoded_) { - int ok = ALPHDecode(dec, row, num_rows); + int ok; + if (dec->alph_dec_ == NULL) { // Initialize decoder. + assert(dec->alpha_plane_ != NULL); + dec->alph_dec_ = ALPHNew(); + if (dec->alph_dec_ == NULL) return NULL; + if (!ALPHInit(dec->alph_dec_, dec->alpha_data_, dec->alpha_data_size_, + io->width, io->height, dec->alpha_plane_)) { + ALPHDelete(dec->alph_dec_); + dec->alph_dec_ = NULL; + return NULL; + } + // if we allowed use of alpha dithering, check whether it's needed at all + if (dec->alph_dec_->pre_processing_ != ALPHA_PREPROCESSED_LEVELS) { + dec->alpha_dithering_ = 0; // disable dithering + } else { + num_rows = height; // decode everything in one pass + } + } + + if (row + num_rows > height) { + num_rows = height - row; + } + + ok = ALPHDecode(dec, row, num_rows); assert(dec->alph_dec_ != NULL); if (!ok || dec->is_alpha_decoded_) { ALPHDelete(dec->alph_dec_);