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

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

Issue 1365903002: Fix a leak in CJBig2_Context. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: CJBig2_Context::decodeFile cannot be reached (please sanity check) Created 5 years, 3 months 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
Index: core/src/fxcodec/jbig2/JBig2_Context.cpp
diff --git a/core/src/fxcodec/jbig2/JBig2_Context.cpp b/core/src/fxcodec/jbig2/JBig2_Context.cpp
index b70054171da8cb001610a002008f51af68febcee..396ae5cd11e9e9e81b7c9b176fe3c23dea1d114e 100644
--- a/core/src/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_Context.cpp
@@ -21,11 +21,10 @@ CJBig2_Context* CJBig2_Context::CreateContext(
FX_DWORD dwGlobalLength,
const uint8_t* pData,
FX_DWORD dwLength,
- int32_t nStreamType,
std::list<CJBig2_CachePair>* pSymbolDictCache,
IFX_Pause* pPause) {
return new CJBig2_Context(pGlobalData, dwGlobalLength, pData, dwLength,
- nStreamType, pSymbolDictCache, pPause);
+ pSymbolDictCache, pPause);
}
void CJBig2_Context::DestroyContext(CJBig2_Context* pContext) {
delete pContext;
@@ -34,18 +33,16 @@ CJBig2_Context::CJBig2_Context(const uint8_t* pGlobalData,
FX_DWORD dwGlobalLength,
const uint8_t* pData,
FX_DWORD dwLength,
- int32_t nStreamType,
std::list<CJBig2_CachePair>* pSymbolDictCache,
IFX_Pause* pPause) {
if (pGlobalData && (dwGlobalLength > 0)) {
- m_pGlobalContext =
- new CJBig2_Context(NULL, 0, pGlobalData, dwGlobalLength,
- JBIG2_EMBED_STREAM, pSymbolDictCache, pPause);
+ m_pGlobalContext = new CJBig2_Context(
+ nullptr, 0, pGlobalData, dwGlobalLength, pSymbolDictCache, pPause);
} else {
- m_pGlobalContext = NULL;
+ m_pGlobalContext = nullptr;
}
+
m_pStream = new CJBig2_BitStream(pData, dwLength);
- m_nStreamType = nStreamType;
m_nState = JBIG2_OUT_OF_PAGE;
m_pPage = NULL;
m_bBufSpecified = FALSE;
@@ -76,40 +73,6 @@ CJBig2_Context::~CJBig2_Context() {
m_pStream = NULL;
}
-int32_t CJBig2_Context::decodeFile(IFX_Pause* pPause) {
- if (m_pStream->getByteLeft() < 8)
- return JBIG2_ERROR_TOO_SHORT;
-
- const uint8_t fileID[] = {0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A};
- if (JBIG2_memcmp(m_pStream->getPointer(), fileID, 8) != 0)
- return JBIG2_ERROR_FILE_FORMAT;
-
- m_pStream->offset(8);
-
- uint8_t cFlags;
- if (m_pStream->read1Byte(&cFlags) != 0)
- return JBIG2_ERROR_TOO_SHORT;
-
- if (!(cFlags & 0x02)) {
- FX_DWORD dwTemp;
- if (m_pStream->readInteger(&dwTemp) != 0)
- return JBIG2_ERROR_TOO_SHORT;
-
- if (dwTemp > 0) {
- m_PageInfoList.clear();
- m_PageInfoList.resize(dwTemp);
- }
- }
-
- if (cFlags & 0x01) {
- m_nStreamType = JBIG2_SQUENTIAL_STREAM;
- return decode_SquentialOrgnazation(pPause);
- }
-
- m_nStreamType = JBIG2_RANDOM_STREAM;
- return decode_RandomOrgnazation_FirstPage(pPause);
-}
-
int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) {
int32_t nRet;
if (m_pStream->getByteLeft() <= 0)
@@ -226,27 +189,7 @@ int32_t CJBig2_Context::Continue(IFX_Pause* pPause) {
m_ProcessingStatus = FXCODEC_STATUS_DECODE_READY;
int32_t nRet;
if (m_PauseStep <= 1) {
- switch (m_nStreamType) {
- case JBIG2_FILE_STREAM:
- nRet = decodeFile(pPause);
- break;
- case JBIG2_SQUENTIAL_STREAM:
- nRet = decode_SquentialOrgnazation(pPause);
- break;
- case JBIG2_RANDOM_STREAM:
- if (m_bFirstPage) {
- nRet = decode_RandomOrgnazation_FirstPage(pPause);
- } else {
- nRet = decode_RandomOrgnazation(pPause);
- }
- break;
- case JBIG2_EMBED_STREAM:
- nRet = decode_EmbedOrgnazation(pPause);
- break;
- default:
- m_ProcessingStatus = FXCODEC_STATUS_ERROR;
- return JBIG2_ERROR_STREAM_TYPE;
- }
+ nRet = decode_EmbedOrgnazation(pPause);
} else if (m_PauseStep == 2) {
nRet = decode_SquentialOrgnazation(pPause);
} else if (m_PauseStep == 3) {
@@ -272,19 +215,7 @@ int32_t CJBig2_Context::Continue(IFX_Pause* pPause) {
}
return nRet;
}
-int32_t CJBig2_Context::getFirstPage(CJBig2_Image** image, IFX_Pause* pPause) {
- int32_t nRet;
- m_bFirstPage = TRUE;
- m_PauseStep = 0;
- if (m_pGlobalContext) {
- nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause);
- if (nRet != JBIG2_SUCCESS) {
- return nRet;
- }
- }
- m_bBufSpecified = FALSE;
- return Continue(pPause);
-}
+
CJBig2_Segment* CJBig2_Context::findSegmentByNumber(FX_DWORD dwNumber) {
CJBig2_Segment* pSeg;
if (m_pGlobalContext) {
« core/src/fxcodec/jbig2/JBig2_Context.h ('K') | « core/src/fxcodec/jbig2/JBig2_Context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698