Add early returns in CJBig2_TRDProc::decode_Arith when decode fails.
None of the decodes in the method are currently being checked. This is
causing pdfium to take a long time rendering corrupted files. Thus, I
added a couple of early returns to help prevent this from happening.
BUG=450971
Review-Url: https://codereview.chromium.org/2493633002
diff --git a/core/fxcodec/jbig2/JBig2_TrdProc.cpp b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
index ccd8ebf..1329cde 100644
--- a/core/fxcodec/jbig2/JBig2_TrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
@@ -266,7 +266,8 @@
std::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH));
SBREG->fill(SBDEFPIXEL);
int32_t STRIPT;
- pIADT->decode(pArithDecoder, &STRIPT);
+ if (!pIADT->decode(pArithDecoder, &STRIPT))
+ return nullptr;
STRIPT *= SBSTRIPS;
STRIPT = -STRIPT;
int32_t FIRSTS = 0;
@@ -274,7 +275,8 @@
while (NINSTANCES < SBNUMINSTANCES) {
int32_t CURS = 0;
int32_t DT;
- pIADT->decode(pArithDecoder, &DT);
+ if (!pIADT->decode(pArithDecoder, &DT))
+ return nullptr;
DT *= SBSTRIPS;
STRIPT += DT;
bool bFirst = true;