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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1514093002: Fix memory leaks involving InsertIndirectObject() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "parser_int.h" 7 #include "parser_int.h"
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 m_SortedOffset.Add(offset); 980 m_SortedOffset.Add(offset);
981 } 981 }
982 FX_Free(buffer); 982 FX_Free(buffer);
983 return m_pTrailer && m_CrossRef.GetSize() > 0; 983 return m_pTrailer && m_CrossRef.GetSize() > 0;
984 } 984 }
985 985
986 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { 986 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
987 CPDF_Object* pObject = ParseIndirectObjectAt(m_pDocument, *pos, 0, nullptr); 987 CPDF_Object* pObject = ParseIndirectObjectAt(m_pDocument, *pos, 0, nullptr);
988 if (!pObject) 988 if (!pObject)
989 return FALSE; 989 return FALSE;
990
991 if (m_pDocument) { 990 if (m_pDocument) {
991 FX_BOOL bInserted = FALSE;
992 CPDF_Dictionary* pDict = m_pDocument->GetRoot(); 992 CPDF_Dictionary* pDict = m_pDocument->GetRoot();
993 if (!pDict || pDict->GetObjNum() != pObject->m_ObjNum) { 993 if ((!pDict || pDict->GetObjNum() != pObject->m_ObjNum)) {
Tom Sepez 2015/12/11 00:15:07 still overparenthesized.
994 m_pDocument->InsertIndirectObject(pObject->m_ObjNum, pObject); 994 bInserted = m_pDocument->InsertIndirectObject(pObject->m_ObjNum, pObject);
995 } else { 995 } else {
996 if (pObject->IsStream()) 996 if (pObject->IsStream())
997 pObject->Release(); 997 pObject->Release();
998 }
999 if (!bInserted)
998 return FALSE; 1000 return FALSE;
999 }
1000 } 1001 }
1001 1002
1002 CPDF_Stream* pStream = pObject->AsStream(); 1003 CPDF_Stream* pStream = pObject->AsStream();
1003 if (!pStream) 1004 if (!pStream)
1004 return FALSE; 1005 return FALSE;
1005 1006
1006 *pos = pStream->GetDict()->GetInteger(FX_BSTRC("Prev")); 1007 *pos = pStream->GetDict()->GetInteger(FX_BSTRC("Prev"));
1007 int32_t size = pStream->GetDict()->GetInteger(FX_BSTRC("Size")); 1008 int32_t size = pStream->GetDict()->GetInteger(FX_BSTRC("Size"));
1008 if (size < 0) { 1009 if (size < 0) {
1009 pStream->Release(); 1010 pStream->Release();
(...skipping 3539 matching lines...) Expand 10 before | Expand all | Expand 10 after
4549 FX_BOOL bPagePosGot = m_pHintTables->GetPagePos(index, szPageStartPos, 4550 FX_BOOL bPagePosGot = m_pHintTables->GetPagePos(index, szPageStartPos,
4550 szPageLength, dwObjNum); 4551 szPageLength, dwObjNum);
4551 if (!bPagePosGot) { 4552 if (!bPagePosGot) {
4552 return nullptr; 4553 return nullptr;
4553 } 4554 }
4554 m_syntaxParser.InitParser(m_pFileRead, (FX_DWORD)szPageStartPos); 4555 m_syntaxParser.InitParser(m_pFileRead, (FX_DWORD)szPageStartPos);
4555 CPDF_Object* pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); 4556 CPDF_Object* pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument);
4556 if (!pPageDict) { 4557 if (!pPageDict) {
4557 return nullptr; 4558 return nullptr;
4558 } 4559 }
4559 m_pDocument->InsertIndirectObject(dwObjNum, pPageDict); 4560 if (!m_pDocument->InsertIndirectObject(dwObjNum, pPageDict))
4561 return nullptr;
4560 return pPageDict->GetDict(); 4562 return pPageDict->GetDict();
4561 } 4563 }
4562 } 4564 }
4563 return m_pDocument->GetPage(index); 4565 return m_pDocument->GetPage(index);
4564 } 4566 }
4565 IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( 4567 IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail(
4566 IFX_DownloadHints* pHints) { 4568 IFX_DownloadHints* pHints) {
4567 if (!m_pDocument) { 4569 if (!m_pDocument) {
4568 return FormAvailable; 4570 return FormAvailable;
4569 } 4571 }
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
4950 if (!m_pLinearizedDict) 4952 if (!m_pLinearizedDict)
4951 return -1; 4953 return -1;
4952 CPDF_Array* pRange = m_pLinearizedDict->GetArray(FX_BSTRC("H")); 4954 CPDF_Array* pRange = m_pLinearizedDict->GetArray(FX_BSTRC("H"));
4953 if (!pRange) 4955 if (!pRange)
4954 return -1; 4956 return -1;
4955 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 4957 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
4956 if (!pStreamLen) 4958 if (!pStreamLen)
4957 return -1; 4959 return -1;
4958 return pStreamLen->GetInteger(); 4960 return pStreamLen->GetInteger();
4959 } 4961 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698