diff options
Diffstat (limited to 'core/src/fpdfapi/fpdf_edit')
-rw-r--r-- | core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp | 8 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 7 |
2 files changed, 9 insertions, 6 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp index 243c23fabf..e33a99ba63 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp @@ -48,7 +48,7 @@ void CPDF_PageContentGenerate::GenerateContent() } ProcessImage(buf, (CPDF_ImageObject*)pPageObj); } - CPDF_Object* pContent = pPageDict->GetElementValue("Contents"); + CPDF_Object* pContent = pPageDict ? pPageDict->GetElementValue("Contents") : NULL; if (pContent != NULL) { pPageDict->RemoveAt("Contents"); } @@ -94,7 +94,8 @@ void CPDF_PageContentGenerate::ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObje FX_DWORD dwSavedObjNum = pStream->GetObjNum(); CFX_ByteString name = RealizeResource(pStream, "XObject"); if (dwSavedObjNum == 0) { - pImageObj->m_pImage->Release(); + if (pImageObj->m_pImage) + pImageObj->m_pImage->Release(); pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pStream); } buf << "/" << PDF_NameEncode(name) << " Do Q\n"; @@ -119,7 +120,8 @@ void CPDF_PageContentGenerate::ProcessForm(CFX_ByteTextBuf& buf, FX_LPCBYTE data } void CPDF_PageContentGenerate::TransformContent(CFX_Matrix& matrix) { - CPDF_Object* pContent = m_pPage->m_pFormDict->GetElementValue("Contents"); + CPDF_Dictionary* pDict = m_pPage->m_pFormDict; + CPDF_Object* pContent = pDict ? pDict->GetElementValue("Contents") : NULL; if (!pContent) { return; } diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index bdbcccdf06..9eec7aa4a8 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -334,7 +334,7 @@ void CPDF_FlateEncoder::CloneDict() FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream, FX_BOOL bFlateEncode) { m_Acc.LoadAllData(pStream, TRUE); - if (pStream->GetDict()->KeyExist("Filter") || !bFlateEncode) { + if ((pStream && pStream->GetDict() && pStream->GetDict()->KeyExist("Filter")) || !bFlateEncode) { if (pStream->GetDict()->KeyExist("Filter") && !bFlateEncode) { CPDF_StreamAcc destAcc; destAcc.LoadAllData(pStream); @@ -1482,7 +1482,8 @@ FX_INT32 CPDF_Creator::WriteDoc_Stage1(IFX_Pause *pPause) if (m_bSecurityChanged && (m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0) { m_dwFlags &= ~FPDFCREATE_INCREMENTAL; } - m_pMetadata = m_pDocument->GetRoot()->GetElementValue(FX_BSTRC("Metadata")); + CPDF_Dictionary* pDict = m_pDocument->GetRoot(); + m_pMetadata = pDict ? pDict->GetElementValue(FX_BSTRC("Metadata")) : NULL; if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) { m_pXRefStream = FX_NEW CPDF_XRefStream; m_pXRefStream->Start(); @@ -2032,7 +2033,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault ) if (!m_pIDArray) { FX_LPDWORD pBuffer = NULL; m_pIDArray = CPDF_Array::Create(); - CPDF_Object* pID1 = pOldIDArray->GetElement(0); + CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetElement(0) : NULL; if (pID1) { m_pIDArray->Add(pID1->Clone()); } else { |