summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-06-30 09:49:21 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-06-30 09:49:21 -0700
commit287e11a213d3197ac3e321acf294d903b271c269 (patch)
tree28f6f9dd00331c2748d73f96d818ce04a9775e8d /fpdfsdk/src
parentad30f609702d232f1708a0792d682c3cfaa0e235 (diff)
downloadpdfium-287e11a213d3197ac3e321acf294d903b271c269.tar.xz
Remove "this==NULL" and adjust corresponding callers
BUG= R=thakis@chromium.org Review URL: https://codereview.chromium.org/361553002
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp8
-rw-r--r--fpdfsdk/src/fpdf_ext.cpp6
-rw-r--r--fpdfsdk/src/fpdf_transformpage.cpp8
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp16
-rw-r--r--fpdfsdk/src/fpdfppo.cpp5
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Icon.cpp2
6 files changed, 24 insertions, 21 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
index 0c7cd48553..8e10cc22e3 100644
--- a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
+++ b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
@@ -239,14 +239,16 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString &sAlias)
}
CFX_ByteString sDA;
-
- sDA = FPDF_GetFieldAttr(m_pAnnotDict, "DA")->GetString();
+ CPDF_Object* pObj;
+ if ((pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA")))
+ sDA = pObj->GetString();
if (bWidget)
{
if (sDA.IsEmpty())
{
- sDA = FPDF_GetFieldAttr(pAcroFormDict, "DA")->GetString();
+ pObj = FPDF_GetFieldAttr(pAcroFormDict, "DA");
+ sDA = pObj ? pObj->GetString() : CFX_ByteString();
}
}
diff --git a/fpdfsdk/src/fpdf_ext.cpp b/fpdfsdk/src/fpdf_ext.cpp
index 916cb2069c..93f6e187da 100644
--- a/fpdfsdk/src/fpdf_ext.cpp
+++ b/fpdfsdk/src/fpdf_ext.cpp
@@ -172,15 +172,15 @@ void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code)
if(pRootDict->KeyExist("Names"))
{
CPDF_Dictionary* pNameDict = pRootDict->GetDict("Names");
- if(pNameDict->KeyExist("EmbeddedFiles"))
+ if (pNameDict && pNameDict->KeyExist("EmbeddedFiles"))
{
FPDF_UnSupportError(FPDF_UNSP_DOC_ATTACHMENT);
return;
}
- else if(pNameDict->KeyExist("JavaScript"))
+ else if (pNameDict && pNameDict->KeyExist("JavaScript"))
{
CPDF_Dictionary* pJSDict = pNameDict->GetDict("JavaScript");
- CPDF_Array * pArray = pJSDict->GetArray("Names");
+ CPDF_Array * pArray = pJSDict ? pJSDict->GetArray("Names") : NULL;
if (pArray) {
int nCount = pArray->GetCount();
for(int i=0; i<nCount; i++)
diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp
index 729b1cd9bb..a666666d55 100644
--- a/fpdfsdk/src/fpdf_transformpage.cpp
+++ b/fpdfsdk/src/fpdf_transformpage.cpp
@@ -96,9 +96,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX
CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
- CPDF_Object* pContentObj = pPageDic->GetElement("Contents");
+ CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL;
if(!pContentObj)
- pContentObj = pPageDic->GetArray("Contents");
+ pContentObj = pPageDic ? pPageDic->GetArray("Contents") : NULL;
if(!pContentObj)
return FALSE;
@@ -260,9 +260,9 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,FPDF_CLIPPATH clip
return;
CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
- CPDF_Object* pContentObj = pPageDic->GetElement("Contents");
+ CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL;
if(!pContentObj)
- pContentObj = pPageDic->GetArray("Contents");
+ pContentObj = pPageDic ? pPageDic->GetArray("Contents") : NULL;
if(!pContentObj)
return;
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index 4c9fd35108..2e84aa5dcb 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -102,7 +102,7 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index,
DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
{
CPDF_Page* pPage = (CPDF_Page*)page;
- if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+ if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
return -1;
@@ -112,8 +112,8 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
int rotate = 0;
if(pDict != NULL)
{
- if(pDict->KeyExist("Rotate"))
- rotate = pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90;
+ if (pDict->KeyExist("Rotate"))
+ rotate = pDict->GetElement("Rotate")->GetDirect()? pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90 : 0;
else
{
if(pDict->KeyExist("Parent"))
@@ -123,7 +123,7 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
{
if(pPages->KeyExist("Rotate"))
{
- rotate = pPages->GetElement("Rotate")->GetDirect()->GetInteger() / 90;
+ rotate = pPages->GetElement("Rotate")->GetDirect()? pPages->GetElement("Rotate")->GetDirect()->GetInteger() / 90 : 0;
break;
}
else if(pPages->KeyExist("Parent"))
@@ -144,7 +144,7 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj)
{
CPDF_Page* pPage = (CPDF_Page*)page;
- if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+ if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
return;
@@ -199,7 +199,7 @@ DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT pag
DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page)
{
CPDF_Page* pPage = (CPDF_Page*)page;
- if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+ if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
return -1;
@@ -263,7 +263,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObje
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page)
{
CPDF_Page* pPage = (CPDF_Page*)page;
- if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+ if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
return FALSE;
@@ -318,7 +318,7 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate)
{
CPDF_Page* pPage = (CPDF_Page*)page;
- if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+ if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
return;
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index a803454cc0..032c3dba39 100644
--- a/fpdfsdk/src/fpdfppo.cpp
+++ b/fpdfsdk/src/fpdfppo.cpp
@@ -64,7 +64,7 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document *pDestPDFDoc, CPDF_Document
pNewRoot->SetAt("Type", new CPDF_Name("Catalog"));
}
- CPDF_Dictionary* pNewPages = (CPDF_Dictionary*)pNewRoot->GetElement("Pages")->GetDirect();
+ CPDF_Dictionary* pNewPages = (CPDF_Dictionary*)(pNewRoot->GetElement("Pages")? pNewRoot->GetElement("Pages")->GetDirect() : NULL);
if(!pNewPages)
{
pNewPages = new CPDF_Dictionary;
@@ -311,7 +311,8 @@ int CPDF_PageOrganizer::GetNewObjId(CPDF_Document *pDoc, CFX_MapPtrToPtr* pMapPt
else
{
CPDF_Object* pClone = pRef->GetDirect()->Clone();
- if(!pClone) return 0;
+ if(!pClone)
+ return 0;
if(pClone->GetType() == PDFOBJ_DICTIONARY)
{
diff --git a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp b/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
index b85b845553..5e3e6e5586 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
@@ -160,7 +160,7 @@ void CPWL_Icon::GetIconPosition(FX_FLOAT & fLeft, FX_FLOAT & fBottom)
//m_pIconFit->GetIconPosition(fLeft,fBottom);
fLeft = 0.0f;
fBottom = 0.0f;
- CPDF_Array* pA = m_pIconFit->m_pDict->GetArray("A");
+ CPDF_Array* pA = m_pIconFit->m_pDict ? m_pIconFit->m_pDict->GetArray("A") : NULL;
if (pA != NULL)
{
FX_DWORD dwCount = pA->GetCount();