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

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp

Issue 441503003: Fix the problem that memory is accessed after released due to invalid type-cast (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
index cd100a80cc07c56f61e210855819f39904fd4578..635fc6b0ee3794da98890244d159f3701ad62ce1 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
@@ -192,9 +192,9 @@ int CPDF_Document::_FindPageIndex(CPDF_Dictionary* pNode, FX_DWORD& skip_count,
}
if (count && count == pKidList->GetCount()) {
for (FX_DWORD i = 0; i < count; i ++) {
- CPDF_Reference* pKid = (CPDF_Reference*)pKidList->GetElement(i);
+ CPDF_Object* pKid = pKidList->GetElement(i);
if (pKid && pKid->GetType() == PDFOBJ_REFERENCE) {
- if (pKid->GetRefObjNum() == objnum) {
+ if (((CPDF_Reference*) pKid)->GetRefObjNum() == objnum) {
m_PageList.SetAt(index + i, objnum);
return index + i;
}
@@ -345,8 +345,11 @@ FX_BOOL CPDF_Document::IsContentUsedElsewhere(FX_DWORD objnum, CPDF_Dictionary*
if (pContents->GetDirectType() == PDFOBJ_ARRAY) {
CPDF_Array* pArray = (CPDF_Array*)pContents->GetDirect();
for (FX_DWORD j = 0; j < pArray->GetCount(); j ++) {
- CPDF_Reference* pRef = (CPDF_Reference*)pArray->GetElement(j);
- if (pRef->GetRefObjNum() == objnum) {
+ CPDF_Object* pRef = pArray->GetElement(j);
+ if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) {
+ continue;
+ }
+ if (((CPDF_Reference*) pRef)->GetRefObjNum() == objnum) {
return TRUE;
}
}
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698