summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fpdfapi/fpdf_page')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp5
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp15
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp21
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_new.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp2
9 files changed, 35 insertions, 28 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index 3cfb93e4bc..500fe4a57f 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -841,7 +841,8 @@ void CPDF_Page::Load(CPDF_Document* pDocument, CPDF_Dictionary* pPageDict, FX_BO
m_pPageResources = m_pResources = NULL;
return;
}
- m_pResources = GetPageAttr(FX_BSTRC("Resources"))->GetDict();
+ CPDF_Object* pageAttr = GetPageAttr(FX_BSTRC("Resources"));
+ m_pResources = pageAttr ? pageAttr->GetDict() : NULL;
m_pPageResources = m_pResources;
CPDF_Object* pRotate = GetPageAttr(FX_BSTRC("Rotate"));
int rotate = 0;
@@ -946,7 +947,7 @@ CPDF_Form::CPDF_Form(CPDF_Document* pDoc, CPDF_Dictionary* pPageResources, CPDF_
{
m_pDocument = pDoc;
m_pFormStream = pFormStream;
- m_pFormDict = pFormStream->GetDict();
+ m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL;
m_pResources = m_pFormDict->GetDict(FX_BSTRC("Resources"));
m_pPageResources = pPageResources;
if (m_pResources == NULL) {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
index c13395c7ce..ff44c591c7 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
@@ -281,7 +281,7 @@ FX_BOOL CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint"));
int i;
for (i = 0; i < 3; i ++) {
- m_WhitePoint[i] = pParam->GetNumber(i);
+ m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0;
}
pParam = pDict->GetArray(FX_BSTRC("BlackPoint"));
for (i = 0; i < 3; i ++) {
@@ -340,7 +340,7 @@ FX_BOOL CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint"));
int i;
for (i = 0; i < 3; i ++) {
- m_WhitePoint[i] = pParam->GetNumber(i);
+ m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0;
}
pParam = pDict->GetArray(FX_BSTRC("BlackPoint"));
for (i = 0; i < 3; i ++) {
@@ -438,7 +438,7 @@ FX_BOOL CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint"));
int i;
for (i = 0; i < 3; i ++) {
- m_WhitePoint[i] = pParam->GetNumber(i);
+ m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0;
}
pParam = pDict->GetArray(FX_BSTRC("BlackPoint"));
for (i = 0; i < 3; i ++) {
@@ -580,11 +580,12 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
if (pStream == NULL) {
return FALSE;
}
- m_nComponents = pStream->GetDict()->GetInteger(FX_BSTRC("N"));
+ CPDF_Dictionary* pDict = pStream->GetDict();
+ m_nComponents = pDict ? pDict->GetInteger(FX_BSTRC("N")) : 0;
if (m_nComponents < 0 || m_nComponents > (1 << 16)) {
return FALSE;
}
- CPDF_Array* pRanges = pStream->GetDict()->GetArray(FX_BSTRC("Range"));
+ CPDF_Array* pRanges = pDict->GetArray(FX_BSTRC("Range"));
m_pRanges = FX_Alloc(FX_FLOAT, m_nComponents * 2);
for (int i = 0; i < m_nComponents * 2; i ++) {
if (pRanges) {
@@ -600,7 +601,7 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
return FALSE;
}
if (m_pProfile->m_pTransform == NULL) {
- CPDF_Object* pAlterCSObj = pStream->GetDict()->GetElementValue(FX_BSTRC("Alternate"));
+ CPDF_Object* pAlterCSObj = pDict ? pDict->GetElementValue(FX_BSTRC("Alternate")) : NULL;
if (pAlterCSObj) {
CPDF_ColorSpace* alter_cs = CPDF_ColorSpace::Load(pDoc, pAlterCSObj);
if (alter_cs) {
@@ -1079,7 +1080,7 @@ CPDF_ColorSpace* CPDF_ColorSpace::Load(CPDF_Document* pDoc, CPDF_Object* pObj)
while (pos) {
CFX_ByteString bsKey;
CPDF_Object *pValue = pDict->GetNextElement(pos, bsKey);
- if (pValue->GetType() == PDFOBJ_NAME) {
+ if (pValue && pValue->GetType() == PDFOBJ_NAME) {
pRet = _CSFromName(pValue->GetString());
}
if (pRet) {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
index a9d2c4d695..c152b223c9 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
@@ -485,7 +485,7 @@ CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj, FX_BOOL bSh
if (bShading) {
pPattern = FX_NEW CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, bShading, matrix);
} else {
- CPDF_Dictionary* pDict = pPatternObj->GetDict();
+ CPDF_Dictionary* pDict = pPatternObj ? pPatternObj->GetDict() : NULL;
if (pDict) {
int type = pDict->GetInteger(FX_BSTRC("PatternType"));
if (type == 1) {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
index 5b178f955e..af22c5649e 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
@@ -486,7 +486,7 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj)
int i;
FX_DWORD nTotalSamples = 1;
for (i = 0; i < m_nInputs; i ++) {
- m_pEncodeInfo[i].sizes = pSize->GetInteger(i);
+ m_pEncodeInfo[i].sizes = pSize ? pSize->GetInteger(i) : 0;
if (!pSize && i == 0) {
m_pEncodeInfo[i].sizes = pDict->GetInteger(FX_BSTRC("Size"));
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
index f53a5b23a4..628fb3da99 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -194,7 +194,8 @@ void CPDF_ClipPath::AppendTexts(CPDF_TextObject** pTexts, int count)
CPDF_ClipPathData* pData = GetModify();
if (pData->m_TextCount + count > FPDF_CLIPPATH_MAX_TEXTS) {
for (int i = 0; i < count; i ++) {
- pTexts[i]->Release();
+ if (pTexts[i])
+ pTexts[i]->Release();
}
return;
}
@@ -481,7 +482,8 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, CPDF_StreamContentParser
FX_POSITION pos = pGS->GetStartPos();
while (pos) {
CFX_ByteString key_str;
- CPDF_Object* pObject = pGS->GetNextElement(pos, key_str)->GetDirect();
+ CPDF_Object* pElement = pGS->GetNextElement(pos, key_str);
+ CPDF_Object* pObject = pElement ? pElement->GetDirect() : NULL;
if (pObject == NULL) {
continue;
}
@@ -625,7 +627,7 @@ CPDF_ContentMarkItem::CPDF_ContentMarkItem(const CPDF_ContentMarkItem& src)
}
CPDF_ContentMarkItem::~CPDF_ContentMarkItem()
{
- if (m_ParamType == DirectDict) {
+ if (m_ParamType == DirectDict && m_pParam) {
((CPDF_Dictionary*)m_pParam)->Release();
}
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index ff670965ec..5e8c1b5ec3 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -140,7 +140,8 @@ int CPDF_StreamContentParser::GetNextParamPos()
m_ParamStartPos = 0;
}
if (m_ParamBuf1[m_ParamStartPos].m_Type == 0) {
- m_ParamBuf1[m_ParamStartPos].m_pObject->Release();
+ if (CPDF_Object* pObject = m_ParamBuf1[m_ParamStartPos].m_pObject)
+ pObject->Release();
}
return m_ParamStartPos;
}
@@ -187,7 +188,8 @@ void CPDF_StreamContentParser::ClearAllParams()
FX_DWORD index = m_ParamStartPos;
for (FX_DWORD i = 0; i < m_ParamCount; i ++) {
if (m_ParamBuf1[index].m_Type == 0) {
- m_ParamBuf1[index].m_pObject->Release();
+ if (CPDF_Object* pObject = m_ParamBuf1[index].m_pObject)
+ pObject->Release();
}
index ++;
if (index == PARAM_BUF_SIZE) {
@@ -238,7 +240,7 @@ CFX_ByteString CPDF_StreamContentParser::GetString(FX_DWORD index)
if (param.m_Type == PDFOBJ_NAME) {
return CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len);
}
- if (param.m_Type == 0) {
+ if (param.m_Type == 0 && param.m_pObject) {
return param.m_pObject->GetString();
}
return CFX_ByteString();
@@ -256,7 +258,7 @@ FX_FLOAT CPDF_StreamContentParser::GetNumber(FX_DWORD index)
if (param.m_Type == PDFOBJ_NUMBER) {
return param.m_Number.m_bInteger ? (FX_FLOAT)param.m_Number.m_Integer : param.m_Number.m_Float;
}
- if (param.m_Type == 0) {
+ if (param.m_Type == 0 && param.m_pObject) {
return param.m_pObject->GetNumber();
}
return 0;
@@ -653,7 +655,7 @@ void CPDF_StreamContentParser::Handle_SetDash()
if (m_Options.m_bTextOnly) {
return;
}
- CPDF_Array* pArray = GetObject(1)->GetArray();
+ CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL;
if (pArray == NULL) {
return;
}
@@ -728,7 +730,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject()
m_bResourceMissing = TRUE;
return;
}
- CFX_ByteStringC type = pXObject->GetDict()->GetConstString(FX_BSTRC("Subtype"));
+ CFX_ByteStringC type = pXObject->GetDict() ? pXObject->GetDict()->GetConstString(FX_BSTRC("Subtype")) : CFX_ByteStringC();
if (type == FX_BSTRC("Image")) {
if (m_Options.m_bTextOnly) {
return;
@@ -1425,7 +1427,7 @@ void CPDF_StreamContentParser::Handle_ShowText()
}
void CPDF_StreamContentParser::Handle_ShowText_Positioning()
{
- CPDF_Array* pArray = GetObject(0)->GetArray();
+ CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
if (pArray == NULL) {
return;
}
@@ -1457,10 +1459,11 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning()
pStrs[iSegment] = str;
pKerning[iSegment ++] = 0;
} else {
+ FX_FLOAT num = pObj ? pObj->GetNumber() : 0;
if (iSegment == 0) {
- fInitKerning += pObj->GetNumber();
+ fInitKerning += num;
} else {
- pKerning[iSegment - 1] += pObj->GetNumber();
+ pKerning[iSegment - 1] += num;
}
}
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_new.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_new.cpp
index 5442f9b4ec..24ec7436aa 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_new.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_new.cpp
@@ -498,9 +498,9 @@ void CPDF_StreamContentParser::EndImageDict()
m_bSameLastDict = TRUE;
}
m_ImageSrcBuf.Clear();
- if (m_pLastCloneImageDict) {
+ if (m_pLastCloneImageDict)
m_pLastCloneImageDict->Release();
- }
+
m_pLastCloneImageDict = (CPDF_Dictionary*)m_pLastImageDict->Clone();
if (m_pLastCloneImageDict->KeyExist(FX_BSTRC("Filter"))) {
m_WordState = 10;
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index 8cd9f2bdb5..fe5e59c698 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -91,7 +91,7 @@ void CPDF_StreamContentParser::Handle_BeginImage()
CPDF_Object* pObj = m_pSyntax->ReadNextObject();
if (!key.IsEmpty()) {
pDict->SetAt(key, pObj, m_pDocument);
- } else {
+ } else if (pObj) {
pObj->Release();
}
}
@@ -1064,7 +1064,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause)
} else {
CPDF_Array* pContent = m_pObjects->m_pFormDict->GetArray(FX_BSTRC("Contents"));
m_pStreamArray[m_CurrentOffset] = FX_NEW CPDF_StreamAcc;
- CPDF_Stream* pStreamObj = (CPDF_Stream*)pContent->GetElementValue(m_CurrentOffset);
+ CPDF_Stream* pStreamObj = (CPDF_Stream*)(pContent ? pContent->GetElementValue(m_CurrentOffset) : NULL);
m_pStreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, FALSE);
m_CurrentOffset ++;
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
index 6c6c095980..8cb6dc77dc 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
@@ -97,7 +97,7 @@ FX_BOOL CPDF_ShadingPattern::Load()
if (m_ShadingType != 0) {
return TRUE;
}
- CPDF_Dictionary* pShadingDict = m_pShadingObj->GetDict();
+ CPDF_Dictionary* pShadingDict = m_pShadingObj ? m_pShadingObj->GetDict() : NULL;
if (pShadingDict == NULL) {
return FALSE;
}