summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_Context.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-26 12:21:14 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-26 20:35:00 +0000
commitcdfc035f4ea2e786c7d7820e143c18bdb11fac3f (patch)
tree7ee209e5b3c55f2ce87f5d02d6f5d6fb4058a013 /core/fxcodec/jbig2/JBig2_Context.cpp
parentfb9c11b49ee4fe6c18703d661dcaee498085c4c5 (diff)
downloadpdfium-cdfc035f4ea2e786c7d7820e143c18bdb11fac3f.tar.xz
Pass CJBig2_ArithDecoder to CJBig2_GRDProc as needed.
Avoid holding a stale pointer to it in CJBig2_GRDProc. Bug: 726732 Change-Id: Ia3797a3e087f61bd2126f867fd5a282e873de5bc Reviewed-on: https://pdfium-review.googlesource.com/6050 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcodec/jbig2/JBig2_Context.cpp')
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index c9570022bb..69a9dd0daa 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -1064,7 +1064,6 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
}
if (m_ri.height < 0 || m_ri.width < 0)
return JBIG2_FAILED;
-
pGRD->GBW = m_ri.width;
pGRD->GBH = m_ri.height;
pGRD->MMR = cFlags & 0x01;
@@ -1073,15 +1072,13 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
if (pGRD->MMR == 0) {
if (pGRD->GBTEMPLATE == 0) {
for (int32_t i = 0; i < 8; ++i) {
- if (m_pStream->read1Byte((uint8_t*)&pGRD->GBAT[i]) != 0) {
+ if (m_pStream->read1Byte((uint8_t*)&pGRD->GBAT[i]) != 0)
return JBIG2_ERROR_TOO_SHORT;
- }
}
} else {
for (int32_t i = 0; i < 2; ++i) {
- if (m_pStream->read1Byte((uint8_t*)&pGRD->GBAT[i]) != 0) {
+ if (m_pStream->read1Byte((uint8_t*)&pGRD->GBAT[i]) != 0)
return JBIG2_ERROR_TOO_SHORT;
- }
}
}
}
@@ -1090,10 +1087,8 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
}
pSegment->m_nResultType = JBIG2_IMAGE_POINTER;
if (m_pGRD->MMR == 0) {
- if (m_gbContext.empty()) {
- const size_t size = GetHuffContextSize(m_pGRD->GBTEMPLATE);
- m_gbContext.resize(size);
- }
+ if (m_gbContext.empty())
+ m_gbContext.resize(GetHuffContextSize(m_pGRD->GBTEMPLATE));
if (!m_pArithDecoder) {
m_pArithDecoder =
pdfium::MakeUnique<CJBig2_ArithDecoder>(m_pStream.get());
@@ -1101,7 +1096,8 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
m_pArithDecoder.get(),
&m_gbContext[0], pPause);
} else {
- m_ProcessingStatus = m_pGRD->Continue_decode(pPause);
+ m_ProcessingStatus =
+ m_pGRD->Continue_decode(pPause, m_pArithDecoder.get());
}
if (m_ProcessingStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) {
if (pSegment->m_cFlags.s.type != 36) {
@@ -1119,17 +1115,16 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
(JBig2ComposeOp)(m_ri.flags & 0x03), &Rect);
}
return JBIG2_SUCCESS;
- } else {
- m_pArithDecoder.reset();
- m_gbContext.clear();
- if (!pSegment->m_Result.im) {
- m_ProcessingStatus = FXCODEC_STATUS_ERROR;
- m_pGRD.reset();
- return JBIG2_ERROR_FATAL;
- }
- m_pStream->alignByte();
- m_pStream->offset(2);
}
+ m_pArithDecoder.reset();
+ m_gbContext.clear();
+ if (!pSegment->m_Result.im) {
+ m_ProcessingStatus = FXCODEC_STATUS_ERROR;
+ m_pGRD.reset();
+ return JBIG2_ERROR_FATAL;
+ }
+ m_pStream->alignByte();
+ m_pStream->offset(2);
} else {
m_pGRD->Start_decode_MMR(&pSegment->m_Result.im, m_pStream.get());
if (!pSegment->m_Result.im) {