From c9952e66c588aad6a5996796fb0c96b202e6de0a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 9 Oct 2015 10:04:37 -0700 Subject: Fix a bad refactoring error from commit 8a9ce57. BUG=541323 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1400773002 . --- core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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