From 924b7e968e3aa19e9e916f8437acbf85d92df40e Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 23 Oct 2015 14:14:26 -0700 Subject: XFA: make JBig2_HuffmanTable.cpp match master Includes one array bounds fix. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1412583003 . --- core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'core/src/fxcodec') diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp index 4effbfadef..9d7cd2aee1 100644 --- a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp +++ b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp @@ -146,11 +146,8 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) { } CODES = FX_Alloc(int, NTEMP); int LENMAX = 0; - for (FX_DWORD i = 0; i < NTEMP; ++i) { - if (PREFLEN[i] > LENMAX) { - LENMAX = PREFLEN[i]; - } - } + for (FX_DWORD i = 0; i < NTEMP; ++i) + LENMAX = std::max(PREFLEN[i], LENMAX); std::vector LENCOUNT(LENMAX + 1); for (FX_DWORD i = 0; i < NTEMP; ++i) @@ -159,7 +156,7 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) { std::vector FIRSTCODE(LENMAX + 1); FIRSTCODE[0] = 0; - for (int i = 0; i <= LENMAX; ++i) { + for (int i = 1; i <= LENMAX; ++i) { FIRSTCODE[i] = (FIRSTCODE[i - 1] + LENCOUNT[i - 1]) << 1; int CURCODE = FIRSTCODE[i]; for (FX_DWORD j = 0; j < NTEMP; ++j) { -- cgit v1.2.3