| 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 <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #define _PARSER_OBJECT_LEVLE_ 64 | |
| 16 extern const FX_LPCSTR _PDF_CharType; | 15 extern const FX_LPCSTR _PDF_CharType; |
| 17 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) | 16 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) |
| 18 { | 17 { |
| 19 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type")); | 18 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type")); |
| 20 if (!pType) { | 19 if (!pType) { |
| 21 pType = pDict->GetElementValue(FX_BSTRC("FT")); | 20 pType = pDict->GetElementValue(FX_BSTRC("FT")); |
| 22 if (!pType) { | 21 if (!pType) { |
| 23 return FALSE; | 22 return FALSE; |
| 24 } | 23 } |
| 25 } | 24 } |
| 26 if (pType->GetString() == FX_BSTRC("Sig")) { | 25 if (pType->GetString() == FX_BSTRC("Sig")) { |
| 27 return TRUE; | 26 return TRUE; |
| 28 } | 27 } |
| 29 return FALSE; | 28 return FALSE; |
| 30 } | 29 } |
| 31 static int _CompareFileSize(const void* p1, const void* p2) | 30 static int _CompareFileSize(const void* p1, const void* p2) |
| 32 { | 31 { |
| 33 FX_FILESIZE ret = (*(FX_FILESIZE*)p1) - (*(FX_FILESIZE*)p2); | 32 FX_FILESIZE ret = (*(FX_FILESIZE*)p1) - (*(FX_FILESIZE*)p2); |
| 34 if (ret > 0) { | 33 if (ret > 0) { |
| 35 return 1; | 34 return 1; |
| 36 } | 35 } |
| 37 if (ret < 0) { | 36 if (ret < 0) { |
| 38 return -1; | 37 return -1; |
| 39 } | 38 } |
| 40 return 0; | 39 return 0; |
| 41 } | 40 } |
| 41 |
| 42 CPDF_Parser::CPDF_Parser() | 42 CPDF_Parser::CPDF_Parser() |
| 43 { | 43 { |
| 44 m_pDocument = NULL; | 44 m_pDocument = NULL; |
| 45 m_pTrailer = NULL; | 45 m_pTrailer = NULL; |
| 46 m_pEncryptDict = NULL; | 46 m_pEncryptDict = NULL; |
| 47 m_pSecurityHandler = NULL; | 47 m_pSecurityHandler = NULL; |
| 48 m_pLinearized = NULL; | 48 m_pLinearized = NULL; |
| 49 m_dwFirstPageNo = 0; | 49 m_dwFirstPageNo = 0; |
| 50 m_dwXrefStartObjNum = 0; | 50 m_dwXrefStartObjNum = 0; |
| 51 m_bOwnFileRead = TRUE; | 51 m_bOwnFileRead = TRUE; |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 FX_INT32 offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); | 1210 FX_INT32 offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); |
| 1211 CPDF_SyntaxParser syntax; | 1211 CPDF_SyntaxParser syntax; |
| 1212 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)p
ObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE)); | 1212 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)p
ObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE)); |
| 1213 syntax.InitParser((IFX_FileStream*)file, 0); | 1213 syntax.InitParser((IFX_FileStream*)file, 0); |
| 1214 CPDF_Object* pRet = NULL; | 1214 CPDF_Object* pRet = NULL; |
| 1215 while (n) { | 1215 while (n) { |
| 1216 FX_DWORD thisnum = syntax.GetDirectNum(); | 1216 FX_DWORD thisnum = syntax.GetDirectNum(); |
| 1217 FX_DWORD thisoff = syntax.GetDirectNum(); | 1217 FX_DWORD thisoff = syntax.GetDirectNum(); |
| 1218 if (thisnum == objnum) { | 1218 if (thisnum == objnum) { |
| 1219 syntax.RestorePos(offset + thisoff); | 1219 syntax.RestorePos(offset + thisoff); |
| 1220 pRet = syntax.GetObject(pObjList, 0, 0, 0, pContext); | 1220 pRet = syntax.GetObject(pObjList, 0, 0, pContext); |
| 1221 break; | 1221 break; |
| 1222 } | 1222 } |
| 1223 n --; | 1223 n --; |
| 1224 } | 1224 } |
| 1225 return pRet; | 1225 return pRet; |
| 1226 } | 1226 } |
| 1227 return NULL; | 1227 return NULL; |
| 1228 } | 1228 } |
| 1229 CPDF_StreamAcc* CPDF_Parser::GetObjectStream(FX_DWORD objnum) | 1229 CPDF_StreamAcc* CPDF_Parser::GetObjectStream(FX_DWORD objnum) |
| 1230 { | 1230 { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 word = m_Syntax.GetNextWord(bIsNumber); | 1389 word = m_Syntax.GetNextWord(bIsNumber); |
| 1390 if (!bIsNumber) { | 1390 if (!bIsNumber) { |
| 1391 m_Syntax.RestorePos(SavedPos); | 1391 m_Syntax.RestorePos(SavedPos); |
| 1392 return NULL; | 1392 return NULL; |
| 1393 } | 1393 } |
| 1394 FX_DWORD parser_gennum = FXSYS_atoi(word); | 1394 FX_DWORD parser_gennum = FXSYS_atoi(word); |
| 1395 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { | 1395 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { |
| 1396 m_Syntax.RestorePos(SavedPos); | 1396 m_Syntax.RestorePos(SavedPos); |
| 1397 return NULL; | 1397 return NULL; |
| 1398 } | 1398 } |
| 1399 CPDF_Object* pObj = m_Syntax.GetObject(pObjList, objnum, parser_gennum, 0, p
Context); | 1399 CPDF_Object* pObj = m_Syntax.GetObject(pObjList, objnum, parser_gennum, pCon
text); |
| 1400 FX_FILESIZE endOffset = m_Syntax.SavePos(); | 1400 FX_FILESIZE endOffset = m_Syntax.SavePos(); |
| 1401 CFX_ByteString bsWord = m_Syntax.GetKeyword(); | 1401 CFX_ByteString bsWord = m_Syntax.GetKeyword(); |
| 1402 if (bsWord == FX_BSTRC("endobj")) { | 1402 if (bsWord == FX_BSTRC("endobj")) { |
| 1403 endOffset = m_Syntax.SavePos(); | 1403 endOffset = m_Syntax.SavePos(); |
| 1404 } | 1404 } |
| 1405 m_Syntax.RestorePos(SavedPos); | 1405 m_Syntax.RestorePos(SavedPos); |
| 1406 if (pObj) { | 1406 if (pObj) { |
| 1407 if (!objnum) { | 1407 if (!objnum) { |
| 1408 pObj->m_ObjNum = parser_objnum; | 1408 pObj->m_ObjNum = parser_objnum; |
| 1409 } | 1409 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1430 word = m_Syntax.GetNextWord(bIsNumber); | 1430 word = m_Syntax.GetNextWord(bIsNumber); |
| 1431 if (!bIsNumber) { | 1431 if (!bIsNumber) { |
| 1432 m_Syntax.RestorePos(SavedPos); | 1432 m_Syntax.RestorePos(SavedPos); |
| 1433 return NULL; | 1433 return NULL; |
| 1434 } | 1434 } |
| 1435 FX_DWORD gennum = FXSYS_atoi(word); | 1435 FX_DWORD gennum = FXSYS_atoi(word); |
| 1436 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { | 1436 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { |
| 1437 m_Syntax.RestorePos(SavedPos); | 1437 m_Syntax.RestorePos(SavedPos); |
| 1438 return NULL; | 1438 return NULL; |
| 1439 } | 1439 } |
| 1440 CPDF_Object* pObj = m_Syntax.GetObjectByStrict(pObjList, objnum, gennum, 0,
pContext); | 1440 CPDF_Object* pObj = m_Syntax.GetObjectByStrict(pObjList, objnum, gennum, pCo
ntext); |
| 1441 if (pResultPos) { | 1441 if (pResultPos) { |
| 1442 *pResultPos = m_Syntax.m_Pos; | 1442 *pResultPos = m_Syntax.m_Pos; |
| 1443 } | 1443 } |
| 1444 m_Syntax.RestorePos(SavedPos); | 1444 m_Syntax.RestorePos(SavedPos); |
| 1445 return pObj; | 1445 return pObj; |
| 1446 } | 1446 } |
| 1447 CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() | 1447 CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() |
| 1448 { | 1448 { |
| 1449 if (m_Syntax.GetKeyword() != FX_BSTRC("trailer")) { | 1449 if (m_Syntax.GetKeyword() != FX_BSTRC("trailer")) { |
| 1450 return NULL; | 1450 return NULL; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 m_ObjectStreamMap.RemoveAll(); | 1669 m_ObjectStreamMap.RemoveAll(); |
| 1670 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && !
LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1670 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && !
LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
| 1671 m_LastXRefOffset = 0; | 1671 m_LastXRefOffset = 0; |
| 1672 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; | 1672 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; |
| 1673 return PDFPARSE_ERROR_FORMAT; | 1673 return PDFPARSE_ERROR_FORMAT; |
| 1674 } | 1674 } |
| 1675 FXSYS_qsort(m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FI
LESIZE), _CompareFileSize); | 1675 FXSYS_qsort(m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FI
LESIZE), _CompareFileSize); |
| 1676 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; | 1676 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; |
| 1677 return PDFPARSE_ERROR_SUCCESS; | 1677 return PDFPARSE_ERROR_SUCCESS; |
| 1678 } | 1678 } |
| 1679 |
| 1680 // static |
| 1681 int CPDF_SyntaxParser::s_CurrentRecursionDepth = 0; |
| 1682 |
| 1679 CPDF_SyntaxParser::CPDF_SyntaxParser() | 1683 CPDF_SyntaxParser::CPDF_SyntaxParser() |
| 1680 { | 1684 { |
| 1681 m_pFileAccess = NULL; | 1685 m_pFileAccess = NULL; |
| 1682 m_pCryptoHandler = NULL; | 1686 m_pCryptoHandler = NULL; |
| 1683 m_pFileBuf = NULL; | 1687 m_pFileBuf = NULL; |
| 1684 m_BufSize = CPDF_ModuleMgr::Get()->m_FileBufSize; | 1688 m_BufSize = CPDF_ModuleMgr::Get()->m_FileBufSize; |
| 1685 m_pFileBuf = NULL; | 1689 m_pFileBuf = NULL; |
| 1686 m_MetadataObjnum = 0; | 1690 m_MetadataObjnum = 0; |
| 1687 m_dwWordPos = 0; | 1691 m_dwWordPos = 0; |
| 1688 m_bFileStream = FALSE; | 1692 m_bFileStream = FALSE; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2042 { | 2046 { |
| 2043 GetNextWord(); | 2047 GetNextWord(); |
| 2044 bIsNumber = m_bIsNumber; | 2048 bIsNumber = m_bIsNumber; |
| 2045 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); | 2049 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); |
| 2046 } | 2050 } |
| 2047 CFX_ByteString CPDF_SyntaxParser::GetKeyword() | 2051 CFX_ByteString CPDF_SyntaxParser::GetKeyword() |
| 2048 { | 2052 { |
| 2049 GetNextWord(); | 2053 GetNextWord(); |
| 2050 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); | 2054 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); |
| 2051 } | 2055 } |
| 2052 CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
RD objnum, FX_DWORD gennum, FX_INT32 level, PARSE_CONTEXT* pContext, FX_BOOL bDe
crypt) | 2056 CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
RD objnum, FX_DWORD gennum, PARSE_CONTEXT* pContext, FX_BOOL bDecrypt) |
| 2053 { | 2057 { |
| 2054 if (level > _PARSER_OBJECT_LEVLE_) { | 2058 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); |
| 2059 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) { |
| 2055 return NULL; | 2060 return NULL; |
| 2056 } | 2061 } |
| 2057 FX_FILESIZE SavedPos = m_Pos; | 2062 FX_FILESIZE SavedPos = m_Pos; |
| 2058 FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); | 2063 FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); |
| 2059 FX_BOOL bIsNumber; | 2064 FX_BOOL bIsNumber; |
| 2060 CFX_ByteString word = GetNextWord(bIsNumber); | 2065 CFX_ByteString word = GetNextWord(bIsNumber); |
| 2061 CPDF_Object* pRet = NULL; | 2066 CPDF_Object* pRet = NULL; |
| 2062 if (word.GetLength() == 0) { | 2067 if (word.GetLength() == 0) { |
| 2063 if (bTypeOnly) { | 2068 if (bTypeOnly) { |
| 2064 return (CPDF_Object*)PDFOBJ_INVALID; | 2069 return (CPDF_Object*)PDFOBJ_INVALID; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 } | 2134 } |
| 2130 pRet = CPDF_String::Create(str, TRUE); | 2135 pRet = CPDF_String::Create(str, TRUE); |
| 2131 return pRet; | 2136 return pRet; |
| 2132 } | 2137 } |
| 2133 if (word == FX_BSTRC("[")) { | 2138 if (word == FX_BSTRC("[")) { |
| 2134 if (bTypeOnly) { | 2139 if (bTypeOnly) { |
| 2135 return (CPDF_Object*)PDFOBJ_ARRAY; | 2140 return (CPDF_Object*)PDFOBJ_ARRAY; |
| 2136 } | 2141 } |
| 2137 CPDF_Array* pArray = CPDF_Array::Create(); | 2142 CPDF_Array* pArray = CPDF_Array::Create(); |
| 2138 while (1) { | 2143 while (1) { |
| 2139 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, level + 1); | 2144 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum); |
| 2140 if (pObj == NULL) { | 2145 if (pObj == NULL) { |
| 2141 return pArray; | 2146 return pArray; |
| 2142 } | 2147 } |
| 2143 pArray->Add(pObj); | 2148 pArray->Add(pObj); |
| 2144 } | 2149 } |
| 2145 } | 2150 } |
| 2146 if (word[0] == '/') { | 2151 if (word[0] == '/') { |
| 2147 if (bTypeOnly) { | 2152 if (bTypeOnly) { |
| 2148 return (CPDF_Object*)PDFOBJ_NAME; | 2153 return (CPDF_Object*)PDFOBJ_NAME; |
| 2149 } | 2154 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2181 break; | 2186 break; |
| 2182 } | 2187 } |
| 2183 if (key[0] != '/') { | 2188 if (key[0] != '/') { |
| 2184 continue; | 2189 continue; |
| 2185 } | 2190 } |
| 2186 nKeys ++; | 2191 nKeys ++; |
| 2187 key = PDF_NameDecode(key); | 2192 key = PDF_NameDecode(key); |
| 2188 if (key == FX_BSTRC("/Contents")) { | 2193 if (key == FX_BSTRC("/Contents")) { |
| 2189 dwSignValuePos = m_Pos; | 2194 dwSignValuePos = m_Pos; |
| 2190 } | 2195 } |
| 2191 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, level + 1); | 2196 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum); |
| 2192 if (pObj == NULL) { | 2197 if (pObj == NULL) { |
| 2193 continue; | 2198 continue; |
| 2194 } | 2199 } |
| 2195 if (key.GetLength() >= 1) { | 2200 if (key.GetLength() >= 1) { |
| 2196 if (nKeys < 32) { | 2201 if (nKeys < 32) { |
| 2197 pDict->SetAt(CFX_ByteStringC(key.c_str() + 1, key.GetLength(
) - 1), pObj); | 2202 pDict->SetAt(CFX_ByteStringC(key.c_str() + 1, key.GetLength(
) - 1), pObj); |
| 2198 } else { | 2203 } else { |
| 2199 pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLeng
th() - 1), pObj); | 2204 pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLeng
th() - 1), pObj); |
| 2200 } | 2205 } |
| 2201 } | 2206 } |
| 2202 } | 2207 } |
| 2203 if (IsSignatureDict(pDict)) { | 2208 if (IsSignatureDict(pDict)) { |
| 2204 FX_FILESIZE dwSavePos = m_Pos; | 2209 FX_FILESIZE dwSavePos = m_Pos; |
| 2205 m_Pos = dwSignValuePos; | 2210 m_Pos = dwSignValuePos; |
| 2206 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, level + 1, N
ULL, FALSE); | 2211 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, NULL, FALSE)
; |
| 2207 pDict->SetAt(FX_BSTRC("Contents"), pObj); | 2212 pDict->SetAt(FX_BSTRC("Contents"), pObj); |
| 2208 m_Pos = dwSavePos; | 2213 m_Pos = dwSavePos; |
| 2209 } | 2214 } |
| 2210 if (pContext) { | 2215 if (pContext) { |
| 2211 pContext->m_DictEnd = m_Pos; | 2216 pContext->m_DictEnd = m_Pos; |
| 2212 if (pContext->m_Flags & PDFPARSE_NOSTREAM) { | 2217 if (pContext->m_Flags & PDFPARSE_NOSTREAM) { |
| 2213 return pDict; | 2218 return pDict; |
| 2214 } | 2219 } |
| 2215 } | 2220 } |
| 2216 FX_FILESIZE SavedPos = m_Pos; | 2221 FX_FILESIZE SavedPos = m_Pos; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2231 } | 2236 } |
| 2232 if (word == FX_BSTRC(">>")) { | 2237 if (word == FX_BSTRC(">>")) { |
| 2233 m_Pos = SavedPos; | 2238 m_Pos = SavedPos; |
| 2234 return NULL; | 2239 return NULL; |
| 2235 } | 2240 } |
| 2236 if (bTypeOnly) { | 2241 if (bTypeOnly) { |
| 2237 return (CPDF_Object*)PDFOBJ_INVALID; | 2242 return (CPDF_Object*)PDFOBJ_INVALID; |
| 2238 } | 2243 } |
| 2239 return NULL; | 2244 return NULL; |
| 2240 } | 2245 } |
| 2241 CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList
, FX_DWORD objnum, FX_DWORD gennum, | 2246 CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList
, FX_DWORD objnum, FX_DWORD gennum, struct PARSE_CONTEXT* pContext) |
| 2242 FX_INT32 level, struct PARSE_CONTEXT* pContext) | |
| 2243 { | 2247 { |
| 2244 if (level > _PARSER_OBJECT_LEVLE_) { | 2248 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); |
| 2249 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) { |
| 2245 return NULL; | 2250 return NULL; |
| 2246 } | 2251 } |
| 2247 FX_FILESIZE SavedPos = m_Pos; | 2252 FX_FILESIZE SavedPos = m_Pos; |
| 2248 FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); | 2253 FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); |
| 2249 FX_BOOL bIsNumber; | 2254 FX_BOOL bIsNumber; |
| 2250 CFX_ByteString word = GetNextWord(bIsNumber); | 2255 CFX_ByteString word = GetNextWord(bIsNumber); |
| 2251 if (word.GetLength() == 0) { | 2256 if (word.GetLength() == 0) { |
| 2252 if (bTypeOnly) { | 2257 if (bTypeOnly) { |
| 2253 return (CPDF_Object*)PDFOBJ_INVALID; | 2258 return (CPDF_Object*)PDFOBJ_INVALID; |
| 2254 } | 2259 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 m_pCryptoHandler->Decrypt(objnum, gennum, str); | 2316 m_pCryptoHandler->Decrypt(objnum, gennum, str); |
| 2312 } | 2317 } |
| 2313 return CPDF_String::Create(str, TRUE); | 2318 return CPDF_String::Create(str, TRUE); |
| 2314 } | 2319 } |
| 2315 if (word == FX_BSTRC("[")) { | 2320 if (word == FX_BSTRC("[")) { |
| 2316 if (bTypeOnly) { | 2321 if (bTypeOnly) { |
| 2317 return (CPDF_Object*)PDFOBJ_ARRAY; | 2322 return (CPDF_Object*)PDFOBJ_ARRAY; |
| 2318 } | 2323 } |
| 2319 CPDF_Array* pArray = CPDF_Array::Create(); | 2324 CPDF_Array* pArray = CPDF_Array::Create(); |
| 2320 while (1) { | 2325 while (1) { |
| 2321 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, level + 1); | 2326 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum); |
| 2322 if (pObj == NULL) { | 2327 if (pObj == NULL) { |
| 2323 if (m_WordBuffer[0] == ']') { | 2328 if (m_WordBuffer[0] == ']') { |
| 2324 return pArray; | 2329 return pArray; |
| 2325 } | 2330 } |
| 2326 if (pArray) | 2331 if (pArray) |
| 2327 pArray->Release(); | 2332 pArray->Release(); |
| 2328 return NULL; | 2333 return NULL; |
| 2329 } | 2334 } |
| 2330 pArray->Add(pObj); | 2335 pArray->Add(pObj); |
| 2331 } | 2336 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2357 break; | 2362 break; |
| 2358 } | 2363 } |
| 2359 if (key == FX_BSTRC("endobj")) { | 2364 if (key == FX_BSTRC("endobj")) { |
| 2360 m_Pos = SavedPos; | 2365 m_Pos = SavedPos; |
| 2361 break; | 2366 break; |
| 2362 } | 2367 } |
| 2363 if (key[0] != '/') { | 2368 if (key[0] != '/') { |
| 2364 continue; | 2369 continue; |
| 2365 } | 2370 } |
| 2366 key = PDF_NameDecode(key); | 2371 key = PDF_NameDecode(key); |
| 2367 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, level + 1); | 2372 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum); |
| 2368 if (pObj == NULL) { | 2373 if (pObj == NULL) { |
| 2369 if (pDict) | 2374 if (pDict) |
| 2370 pDict->Release(); | 2375 pDict->Release(); |
| 2371 FX_BYTE ch; | 2376 FX_BYTE ch; |
| 2372 while (1) { | 2377 while (1) { |
| 2373 if (!GetNextChar(ch)) { | 2378 if (!GetNextChar(ch)) { |
| 2374 break; | 2379 break; |
| 2375 } | 2380 } |
| 2376 if (ch == 0x0A || ch == 0x0D) { | 2381 if (ch == 0x0A || ch == 0x0D) { |
| 2377 break; | 2382 break; |
| (...skipping 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4624 { | 4629 { |
| 4625 FX_INT32 iSize = m_childNode.GetSize(); | 4630 FX_INT32 iSize = m_childNode.GetSize(); |
| 4626 for (FX_INT32 i = 0; i < iSize; ++i) { | 4631 for (FX_INT32 i = 0; i < iSize; ++i) { |
| 4627 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; | 4632 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; |
| 4628 if (pNode) { | 4633 if (pNode) { |
| 4629 delete pNode; | 4634 delete pNode; |
| 4630 } | 4635 } |
| 4631 } | 4636 } |
| 4632 m_childNode.RemoveAll(); | 4637 m_childNode.RemoveAll(); |
| 4633 } | 4638 } |
| OLD | NEW |