Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "../../../include/fpdfapi/fpdf_parser.h" | 7 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "../../../include/fpdfapi/fpdf_page.h" | 9 #include "../../../include/fpdfapi/fpdf_page.h" |
| 10 #include "../../../../third_party/numerics/safe_math.h" | 10 #include "../../../../third_party/numerics/safe_math.h" |
| 11 #include "../fpdf_page/pageint.h" | 11 #include "../fpdf_page/pageint.h" |
| 12 #include <limits.h> | 12 #include <limits.h> |
| 13 #define _PARSER_OBJECT_LEVLE_ 64 | 13 #define _PARSER_OBJECT_LEVLE_ 64 |
| 14 extern const FX_LPCSTR _PDF_CharType; | 14 extern const FX_LPCSTR _PDF_CharType; |
| 15 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) | 15 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) |
| 16 { | 16 { |
| 17 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type")); | 17 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type")); |
| 18 if (!pType) { | 18 if (!pType) { |
| 19 pType = pDict->GetElementValue(FX_BSTRC("FT")); | 19 pType = pDict->GetElementValue(FX_BSTRC("FT")); |
| 20 if (!pType) { | 20 if (!pType) { |
| 21 return FALSE; | 21 return FALSE; |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 if (pType->GetString() == FX_BSTRC("Sig")) { | 24 if (pType->GetString() == FX_BSTRC("Sig")) { |
| 25 return TRUE; | 25 return TRUE; |
| 26 } | 26 } |
| 27 return FALSE; | 27 return FALSE; |
| 28 } | 28 } |
| 29 static FX_INT32 _CompareDWord(const void* p1, const void* p2) | 29 static FX_INT32 _CompareDWord(const void* p1, const void* p2) |
|
Lei Zhang
2014/07/17 23:16:15
Now _CompareDword() is no longer used.
| |
| 30 { | 30 { |
| 31 return (*(FX_DWORD*)p1) - (*(FX_DWORD*)p2); | 31 return (*(FX_DWORD*)p1) - (*(FX_DWORD*)p2); |
| 32 } | 32 } |
| 33 static int _CompareFileSize(const void* p1, const void* p2) | 33 static int _CompareFileSize(const void* p1, const void* p2) |
| 34 { | 34 { |
| 35 FX_FILESIZE ret = (*(FX_FILESIZE*)p1) - (*(FX_FILESIZE*)p2); | 35 FX_FILESIZE ret = (*(FX_FILESIZE*)p1) - (*(FX_FILESIZE*)p2); |
| 36 if (ret > 0) { | 36 if (ret > 0) { |
| 37 return 1; | 37 return 1; |
| 38 } | 38 } |
| 39 if (ret < 0) { | 39 if (ret < 0) { |
| (...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1643 CPDF_StreamAcc* pStream; | 1643 CPDF_StreamAcc* pStream; |
| 1644 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); | 1644 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); |
| 1645 delete pStream; | 1645 delete pStream; |
| 1646 } | 1646 } |
| 1647 m_ObjectStreamMap.RemoveAll(); | 1647 m_ObjectStreamMap.RemoveAll(); |
| 1648 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && ! LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1648 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && ! LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
| 1649 m_LastXRefOffset = 0; | 1649 m_LastXRefOffset = 0; |
| 1650 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; | 1650 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; |
| 1651 return PDFPARSE_ERROR_FORMAT; | 1651 return PDFPARSE_ERROR_FORMAT; |
| 1652 } | 1652 } |
| 1653 FXSYS_qsort(m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_DW ORD), _CompareDWord); | 1653 FXSYS_qsort(m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FI LESIZE), _CompareFileSize); |
| 1654 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; | 1654 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; |
| 1655 return PDFPARSE_ERROR_SUCCESS; | 1655 return PDFPARSE_ERROR_SUCCESS; |
| 1656 } | 1656 } |
| 1657 CPDF_SyntaxParser::CPDF_SyntaxParser() | 1657 CPDF_SyntaxParser::CPDF_SyntaxParser() |
| 1658 { | 1658 { |
| 1659 m_pFileAccess = NULL; | 1659 m_pFileAccess = NULL; |
| 1660 m_pCryptoHandler = NULL; | 1660 m_pCryptoHandler = NULL; |
| 1661 m_pFileBuf = NULL; | 1661 m_pFileBuf = NULL; |
| 1662 m_BufSize = CPDF_ModuleMgr::Get()->m_FileBufSize; | 1662 m_BufSize = CPDF_ModuleMgr::Get()->m_FileBufSize; |
| 1663 m_pFileBuf = NULL; | 1663 m_pFileBuf = NULL; |
| (...skipping 2720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4384 { | 4384 { |
| 4385 FX_INT32 iSize = m_childNode.GetSize(); | 4385 FX_INT32 iSize = m_childNode.GetSize(); |
| 4386 for (FX_INT32 i = 0; i < iSize; ++i) { | 4386 for (FX_INT32 i = 0; i < iSize; ++i) { |
| 4387 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; | 4387 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; |
| 4388 if (pNode) { | 4388 if (pNode) { |
| 4389 delete pNode; | 4389 delete pNode; |
| 4390 } | 4390 } |
| 4391 } | 4391 } |
| 4392 m_childNode.RemoveAll(); | 4392 m_childNode.RemoveAll(); |
| 4393 } | 4393 } |
| OLD | NEW |