Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp

Issue 1534323002: Fix the JBIG2 decoding regressions from commit bc4b82e and 8a9ce57. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Context.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
index 6b6f16109bcaf0737f892260d7804c2f52691cf7..8aaebf46a211ec06a963eef200a15479b93dbd40 100644
--- a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
@@ -103,15 +103,20 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
FX_DWORD HTLOW;
FX_DWORD HTHIGH;
if (pStream->readInteger(&HTLOW) == -1 ||
- pStream->readInteger(&HTHIGH) == -1 || HTLOW > HTHIGH) {
+ pStream->readInteger(&HTHIGH) == -1) {
return FALSE;
}
+ const int low = static_cast<int>(HTLOW);
Tom Sepez 2015/12/18 23:10:50 do you want int32_t here?
+ const int high = static_cast<int>(HTHIGH);
+ if (low > high)
+ return false;
+
FX_DWORD nSize = 16;
PREFLEN = FX_Alloc(int, nSize);
RANGELEN = FX_Alloc(int, nSize);
RANGELOW = FX_Alloc(int, nSize);
- FX_DWORD CURRANGELOW = HTLOW;
+ int cur_low = low;
NTEMP = 0;
do {
HT_CHECK_MEMORY_ADJUST
@@ -119,23 +124,23 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
(pStream->readNBits(HTRS, &RANGELEN[NTEMP]) == -1)) {
return FALSE;
}
- RANGELOW[NTEMP] = CURRANGELOW;
- CURRANGELOW = CURRANGELOW + (1 << RANGELEN[NTEMP]);
+ RANGELOW[NTEMP] = cur_low;
+ cur_low += (1 << RANGELEN[NTEMP]);
NTEMP = NTEMP + 1;
- } while (CURRANGELOW < HTHIGH);
+ } while (cur_low < high);
HT_CHECK_MEMORY_ADJUST
if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1)
return FALSE;
RANGELEN[NTEMP] = 32;
- RANGELOW[NTEMP] = HTLOW - 1;
+ RANGELOW[NTEMP] = low - 1;
++NTEMP;
HT_CHECK_MEMORY_ADJUST
if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1)
return FALSE;
RANGELEN[NTEMP] = 32;
- RANGELOW[NTEMP] = HTHIGH;
+ RANGELOW[NTEMP] = high;
NTEMP = NTEMP + 1;
if (HTOOB) {
HT_CHECK_MEMORY_ADJUST
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Context.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698