From b8d86800487df4021860f08407c323ed82243c79 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 1 Dec 2017 22:52:42 +0000 Subject: Get rid of else after break/continue/return. Change-Id: I3efc57cd7325d16e3ca8ebdeeaec06012b2c56e3 Reviewed-on: https://pdfium-review.googlesource.com/20110 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- core/fxcodec/codec/fx_codec_flate.cpp | 5 +++-- core/fxcodec/jbig2/JBig2_SddProc.cpp | 26 ++++++++++++-------------- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'core/fxcodec') 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_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) { -- cgit v1.2.3