summaryrefslogtreecommitdiff
path: root/core/src/fxcodec/jbig2
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-23 14:14:26 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-23 14:14:26 -0700
commit924b7e968e3aa19e9e916f8437acbf85d92df40e (patch)
treea90fc7caa1153605b6dfcb504bf08e1a8ec4f2ab /core/src/fxcodec/jbig2
parente00d731e207b0f9c476ff7ee2e20a55185fb8861 (diff)
downloadpdfium-924b7e968e3aa19e9e916f8437acbf85d92df40e.tar.xz
XFA: make JBig2_HuffmanTable.cpp match master
Includes one array bounds fix. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1412583003 .
Diffstat (limited to 'core/src/fxcodec/jbig2')
-rw-r--r--core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp9
1 files 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<int> LENCOUNT(LENMAX + 1);
for (FX_DWORD i = 0; i < NTEMP; ++i)
@@ -159,7 +156,7 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
std::vector<int> 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) {