summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/codec/fx_codec_flate.cpp5
-rw-r--r--core/fxcodec/jbig2/JBig2_SddProc.cpp26
2 files changed, 15 insertions, 16 deletions
diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp
index 5b1df38913..95902bb699 100644
--- a/core/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/fxcodec/codec/fx_codec_flate.cpp
@@ -190,6 +190,8 @@ int CLZWDecoder::Decode(uint8_t* dest_buf,
}
}
m_InPos += m_CodeLen;
+ if (code == 257)
+ break;
if (code < 256) {
if (m_OutPos == dest_size) {
return -5;
@@ -206,9 +208,8 @@ int CLZWDecoder::Decode(uint8_t* dest_buf,
m_CodeLen = 9;
m_nCodes = 0;
old_code = 0xFFFFFFFF;
- } else if (code == 257) {
- break;
} else {
+ // Else 257 or greater.
if (old_code == 0xFFFFFFFF)
return 2;
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp
index 43768bd823..ee0c0f37f3 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -310,25 +310,23 @@ std::unique_ptr<CJBig2_SymbolDict> CJBig2_SDDProc::decode_Huffman(
HCFIRSTSYM = NSYMSDECODED;
for (;;) {
nVal = pHuffmanDecoder->decodeAValue(SDHUFFDW, &DW);
- if (nVal == JBIG2_OOB) {
+ if (nVal == JBIG2_OOB)
break;
- } else if (nVal != 0) {
+ if (nVal != 0)
+ return nullptr;
+ if (NSYMSDECODED >= SDNUMNEWSYMS)
return nullptr;
- } else {
- if (NSYMSDECODED >= SDNUMNEWSYMS)
- return nullptr;
- SYMWIDTH = SYMWIDTH + DW;
- if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE) {
- return nullptr;
- } else if (HCHEIGHT == 0 || SYMWIDTH == 0) {
- TOTWIDTH = TOTWIDTH + SYMWIDTH;
- SDNEWSYMS[NSYMSDECODED] = nullptr;
- NSYMSDECODED = NSYMSDECODED + 1;
- continue;
- }
+ SYMWIDTH = SYMWIDTH + DW;
+ if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE)
+ return nullptr;
+ if (HCHEIGHT == 0 || SYMWIDTH == 0) {
TOTWIDTH = TOTWIDTH + SYMWIDTH;
+ SDNEWSYMS[NSYMSDECODED] = nullptr;
+ NSYMSDECODED = NSYMSDECODED + 1;
+ continue;
}
+ TOTWIDTH = TOTWIDTH + SYMWIDTH;
if (SDREFAGG == 1) {
if (pHuffmanDecoder->decodeAValue(SDHUFFAGGINST, (int*)&REFAGGNINST) !=
0) {