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 "parser_int.h" | 7 #include "parser_int.h" |
8 | 8 |
| 9 #include <memory> |
9 #include <set> | 10 #include <set> |
10 #include <utility> | 11 #include <utility> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "core/include/fpdfapi/fpdf_module.h" | 14 #include "core/include/fpdfapi/fpdf_module.h" |
14 #include "core/include/fpdfapi/fpdf_page.h" | 15 #include "core/include/fpdfapi/fpdf_page.h" |
15 #include "core/include/fpdfapi/fpdf_parser.h" | 16 #include "core/include/fpdfapi/fpdf_parser.h" |
16 #include "core/include/fxcrt/fx_ext.h" | 17 #include "core/include/fxcrt/fx_ext.h" |
17 #include "core/include/fxcrt/fx_safe_types.h" | 18 #include "core/include/fxcrt/fx_safe_types.h" |
18 #include "core/src/fpdfapi/fpdf_page/pageint.h" | 19 #include "core/src/fpdfapi/fpdf_page/pageint.h" |
19 #include "third_party/base/nonstd_unique_ptr.h" | |
20 #include "third_party/base/stl_util.h" | 20 #include "third_party/base/stl_util.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // A limit on the size of the xref table. Theoretical limits are higher, but | 24 // A limit on the size of the xref table. Theoretical limits are higher, but |
25 // this may be large enough in practice. | 25 // this may be large enough in practice. |
26 const int32_t kMaxXRefSize = 1048576; | 26 const int32_t kMaxXRefSize = 1048576; |
27 | 27 |
28 // A limit on the maximum object number in the xref table. Theoretical limits | 28 // A limit on the maximum object number in the xref table. Theoretical limits |
29 // are higher, but this may be large enough in practice. | 29 // are higher, but this may be large enough in practice. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const FX_SAFE_DWORD& num_bits) { | 87 const FX_SAFE_DWORD& num_bits) { |
88 return (num_bits.IsValid() && | 88 return (num_bits.IsValid() && |
89 hStream->BitsRemaining() >= num_bits.ValueOrDie()); | 89 hStream->BitsRemaining() >= num_bits.ValueOrDie()); |
90 } | 90 } |
91 | 91 |
92 } // namespace | 92 } // namespace |
93 | 93 |
94 // TODO(thestig) Using unique_ptr with ReleaseDeleter is still not ideal. | 94 // TODO(thestig) Using unique_ptr with ReleaseDeleter is still not ideal. |
95 // Come up or wait for something better. | 95 // Come up or wait for something better. |
96 using ScopedFileStream = | 96 using ScopedFileStream = |
97 nonstd::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>>; | 97 std::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>>; |
98 | 98 |
99 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) { | 99 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) { |
100 CPDF_Object* pType = pDict->GetElementValue("Type"); | 100 CPDF_Object* pType = pDict->GetElementValue("Type"); |
101 if (!pType) { | 101 if (!pType) { |
102 pType = pDict->GetElementValue("FT"); | 102 pType = pDict->GetElementValue("FT"); |
103 if (!pType) { | 103 if (!pType) { |
104 return FALSE; | 104 return FALSE; |
105 } | 105 } |
106 } | 106 } |
107 if (pType->GetString() == "Sig") { | 107 if (pType->GetString() == "Sig") { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 300 } |
301 } | 301 } |
302 if (m_bForceUseSecurityHandler) { | 302 if (m_bForceUseSecurityHandler) { |
303 FX_DWORD err = PDFPARSE_ERROR_HANDLER; | 303 FX_DWORD err = PDFPARSE_ERROR_HANDLER; |
304 if (!m_pSecurityHandler) { | 304 if (!m_pSecurityHandler) { |
305 return PDFPARSE_ERROR_HANDLER; | 305 return PDFPARSE_ERROR_HANDLER; |
306 } | 306 } |
307 if (!m_pSecurityHandler->OnInit(this, m_pEncryptDict)) { | 307 if (!m_pSecurityHandler->OnInit(this, m_pEncryptDict)) { |
308 return err; | 308 return err; |
309 } | 309 } |
310 nonstd::unique_ptr<CPDF_CryptoHandler> pCryptoHandler( | 310 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler( |
311 m_pSecurityHandler->CreateCryptoHandler()); | 311 m_pSecurityHandler->CreateCryptoHandler()); |
312 if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) { | 312 if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) { |
313 return PDFPARSE_ERROR_HANDLER; | 313 return PDFPARSE_ERROR_HANDLER; |
314 } | 314 } |
315 m_Syntax.SetEncrypt(pCryptoHandler.release()); | 315 m_Syntax.SetEncrypt(pCryptoHandler.release()); |
316 } else if (m_pEncryptDict) { | 316 } else if (m_pEncryptDict) { |
317 CFX_ByteString filter = m_pEncryptDict->GetString("Filter"); | 317 CFX_ByteString filter = m_pEncryptDict->GetString("Filter"); |
318 nonstd::unique_ptr<CPDF_SecurityHandler> pSecurityHandler; | 318 std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler; |
319 FX_DWORD err = PDFPARSE_ERROR_HANDLER; | 319 FX_DWORD err = PDFPARSE_ERROR_HANDLER; |
320 if (filter == "Standard") { | 320 if (filter == "Standard") { |
321 pSecurityHandler.reset(FPDF_CreateStandardSecurityHandler()); | 321 pSecurityHandler.reset(FPDF_CreateStandardSecurityHandler()); |
322 err = PDFPARSE_ERROR_PASSWORD; | 322 err = PDFPARSE_ERROR_PASSWORD; |
323 } | 323 } |
324 if (!pSecurityHandler) { | 324 if (!pSecurityHandler) { |
325 return PDFPARSE_ERROR_HANDLER; | 325 return PDFPARSE_ERROR_HANDLER; |
326 } | 326 } |
327 if (!pSecurityHandler->OnInit(this, m_pEncryptDict)) { | 327 if (!pSecurityHandler->OnInit(this, m_pEncryptDict)) { |
328 return err; | 328 return err; |
329 } | 329 } |
330 m_pSecurityHandler = std::move(pSecurityHandler); | 330 m_pSecurityHandler = std::move(pSecurityHandler); |
331 nonstd::unique_ptr<CPDF_CryptoHandler> pCryptoHandler( | 331 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler( |
332 m_pSecurityHandler->CreateCryptoHandler()); | 332 m_pSecurityHandler->CreateCryptoHandler()); |
333 if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) { | 333 if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) { |
334 return PDFPARSE_ERROR_HANDLER; | 334 return PDFPARSE_ERROR_HANDLER; |
335 } | 335 } |
336 m_Syntax.SetEncrypt(pCryptoHandler.release()); | 336 m_Syntax.SetEncrypt(pCryptoHandler.release()); |
337 } | 337 } |
338 return PDFPARSE_ERROR_SUCCESS; | 338 return PDFPARSE_ERROR_SUCCESS; |
339 } | 339 } |
340 void CPDF_Parser::ReleaseEncryptHandler() { | 340 void CPDF_Parser::ReleaseEncryptHandler() { |
341 m_Syntax.m_pCryptoHandler.reset(); | 341 m_Syntax.m_pCryptoHandler.reset(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 return FALSE; | 378 return FALSE; |
379 } | 379 } |
380 FX_FILESIZE newxrefpos = GetDirectInteger(m_pTrailer, "Prev"); | 380 FX_FILESIZE newxrefpos = GetDirectInteger(m_pTrailer, "Prev"); |
381 if (newxrefpos == xrefpos) { | 381 if (newxrefpos == xrefpos) { |
382 return FALSE; | 382 return FALSE; |
383 } | 383 } |
384 xrefpos = newxrefpos; | 384 xrefpos = newxrefpos; |
385 while (xrefpos) { | 385 while (xrefpos) { |
386 CrossRefList.InsertAt(0, xrefpos); | 386 CrossRefList.InsertAt(0, xrefpos); |
387 LoadCrossRefV4(xrefpos, 0, TRUE); | 387 LoadCrossRefV4(xrefpos, 0, TRUE); |
388 nonstd::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( | 388 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( |
389 LoadTrailerV4()); | 389 LoadTrailerV4()); |
390 if (!pDict) | 390 if (!pDict) |
391 return FALSE; | 391 return FALSE; |
392 | 392 |
393 if (!CheckDirectType(pDict.get(), "Prev", PDFOBJ_NUMBER)) | 393 if (!CheckDirectType(pDict.get(), "Prev", PDFOBJ_NUMBER)) |
394 return FALSE; | 394 return FALSE; |
395 | 395 |
396 newxrefpos = GetDirectInteger(pDict.get(), "Prev"); | 396 newxrefpos = GetDirectInteger(pDict.get(), "Prev"); |
397 if (newxrefpos == xrefpos) | 397 if (newxrefpos == xrefpos) |
398 return FALSE; | 398 return FALSE; |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 *pResultPos = m_Syntax.m_Pos; | 1449 *pResultPos = m_Syntax.m_Pos; |
1450 } | 1450 } |
1451 m_Syntax.RestorePos(SavedPos); | 1451 m_Syntax.RestorePos(SavedPos); |
1452 return pObj; | 1452 return pObj; |
1453 } | 1453 } |
1454 | 1454 |
1455 CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() { | 1455 CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() { |
1456 if (m_Syntax.GetKeyword() != "trailer") | 1456 if (m_Syntax.GetKeyword() != "trailer") |
1457 return nullptr; | 1457 return nullptr; |
1458 | 1458 |
1459 nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( | 1459 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( |
1460 m_Syntax.GetObject(m_pDocument, 0, 0, 0)); | 1460 m_Syntax.GetObject(m_pDocument, 0, 0, 0)); |
1461 if (!ToDictionary(pObj.get())) | 1461 if (!ToDictionary(pObj.get())) |
1462 return nullptr; | 1462 return nullptr; |
1463 return pObj.release()->AsDictionary(); | 1463 return pObj.release()->AsDictionary(); |
1464 } | 1464 } |
1465 | 1465 |
1466 FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) { | 1466 FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) { |
1467 if (!m_pSecurityHandler) { | 1467 if (!m_pSecurityHandler) { |
1468 return (FX_DWORD)-1; | 1468 return (FX_DWORD)-1; |
1469 } | 1469 } |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2088 } | 2088 } |
2089 if (word == "<<") { | 2089 if (word == "<<") { |
2090 if (bTypeOnly) | 2090 if (bTypeOnly) |
2091 return (CPDF_Object*)PDFOBJ_DICTIONARY; | 2091 return (CPDF_Object*)PDFOBJ_DICTIONARY; |
2092 | 2092 |
2093 if (pContext) | 2093 if (pContext) |
2094 pContext->m_DictStart = SavedPos; | 2094 pContext->m_DictStart = SavedPos; |
2095 | 2095 |
2096 int32_t nKeys = 0; | 2096 int32_t nKeys = 0; |
2097 FX_FILESIZE dwSignValuePos = 0; | 2097 FX_FILESIZE dwSignValuePos = 0; |
2098 nonstd::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( | 2098 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( |
2099 new CPDF_Dictionary); | 2099 new CPDF_Dictionary); |
2100 while (1) { | 2100 while (1) { |
2101 FX_BOOL bIsNumber; | 2101 FX_BOOL bIsNumber; |
2102 CFX_ByteString key = GetNextWord(bIsNumber); | 2102 CFX_ByteString key = GetNextWord(bIsNumber); |
2103 if (key.IsEmpty()) | 2103 if (key.IsEmpty()) |
2104 return nullptr; | 2104 return nullptr; |
2105 | 2105 |
2106 FX_FILESIZE SavedPos = m_Pos - key.GetLength(); | 2106 FX_FILESIZE SavedPos = m_Pos - key.GetLength(); |
2107 if (key == ">>") | 2107 if (key == ">>") |
2108 break; | 2108 break; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2226 if (bTypeOnly) | 2226 if (bTypeOnly) |
2227 return (CPDF_Object*)PDFOBJ_STRING; | 2227 return (CPDF_Object*)PDFOBJ_STRING; |
2228 CFX_ByteString str = ReadHexString(); | 2228 CFX_ByteString str = ReadHexString(); |
2229 if (m_pCryptoHandler) | 2229 if (m_pCryptoHandler) |
2230 m_pCryptoHandler->Decrypt(objnum, gennum, str); | 2230 m_pCryptoHandler->Decrypt(objnum, gennum, str); |
2231 return new CPDF_String(str, TRUE); | 2231 return new CPDF_String(str, TRUE); |
2232 } | 2232 } |
2233 if (word == "[") { | 2233 if (word == "[") { |
2234 if (bTypeOnly) | 2234 if (bTypeOnly) |
2235 return (CPDF_Object*)PDFOBJ_ARRAY; | 2235 return (CPDF_Object*)PDFOBJ_ARRAY; |
2236 nonstd::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> pArray( | 2236 std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> pArray( |
2237 new CPDF_Array); | 2237 new CPDF_Array); |
2238 while (CPDF_Object* pObj = GetObject(pObjList, objnum, gennum)) | 2238 while (CPDF_Object* pObj = GetObject(pObjList, objnum, gennum)) |
2239 pArray->Add(pObj); | 2239 pArray->Add(pObj); |
2240 return m_WordBuffer[0] == ']' ? pArray.release() : nullptr; | 2240 return m_WordBuffer[0] == ']' ? pArray.release() : nullptr; |
2241 } | 2241 } |
2242 if (word[0] == '/') { | 2242 if (word[0] == '/') { |
2243 if (bTypeOnly) | 2243 if (bTypeOnly) |
2244 return (CPDF_Object*)PDFOBJ_NAME; | 2244 return (CPDF_Object*)PDFOBJ_NAME; |
2245 return new CPDF_Name( | 2245 return new CPDF_Name( |
2246 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); | 2246 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); |
2247 } | 2247 } |
2248 if (word == "<<") { | 2248 if (word == "<<") { |
2249 if (bTypeOnly) | 2249 if (bTypeOnly) |
2250 return (CPDF_Object*)PDFOBJ_DICTIONARY; | 2250 return (CPDF_Object*)PDFOBJ_DICTIONARY; |
2251 if (pContext) | 2251 if (pContext) |
2252 pContext->m_DictStart = SavedPos; | 2252 pContext->m_DictStart = SavedPos; |
2253 | 2253 |
2254 nonstd::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( | 2254 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( |
2255 new CPDF_Dictionary); | 2255 new CPDF_Dictionary); |
2256 while (1) { | 2256 while (1) { |
2257 FX_BOOL bIsNumber; | 2257 FX_BOOL bIsNumber; |
2258 FX_FILESIZE SavedPos = m_Pos; | 2258 FX_FILESIZE SavedPos = m_Pos; |
2259 CFX_ByteString key = GetNextWord(bIsNumber); | 2259 CFX_ByteString key = GetNextWord(bIsNumber); |
2260 if (key.IsEmpty()) | 2260 if (key.IsEmpty()) |
2261 return nullptr; | 2261 return nullptr; |
2262 | 2262 |
2263 if (key == ">>") | 2263 if (key == ">>") |
2264 break; | 2264 break; |
2265 | 2265 |
2266 if (key == "endobj") { | 2266 if (key == "endobj") { |
2267 m_Pos = SavedPos; | 2267 m_Pos = SavedPos; |
2268 break; | 2268 break; |
2269 } | 2269 } |
2270 if (key[0] != '/') | 2270 if (key[0] != '/') |
2271 continue; | 2271 continue; |
2272 | 2272 |
2273 key = PDF_NameDecode(key); | 2273 key = PDF_NameDecode(key); |
2274 nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> obj( | 2274 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> obj( |
2275 GetObject(pObjList, objnum, gennum)); | 2275 GetObject(pObjList, objnum, gennum)); |
2276 if (!obj) { | 2276 if (!obj) { |
2277 uint8_t ch; | 2277 uint8_t ch; |
2278 while (GetNextChar(ch) && ch != 0x0A && ch != 0x0D) { | 2278 while (GetNextChar(ch) && ch != 0x0A && ch != 0x0D) { |
2279 } | 2279 } |
2280 return nullptr; | 2280 return nullptr; |
2281 } | 2281 } |
2282 if (key.GetLength() > 1) { | 2282 if (key.GetLength() > 1) { |
2283 pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1), | 2283 pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1), |
2284 obj.release()); | 2284 obj.release()); |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2877 | 2877 |
2878 FX_BOOL m_bTotalLoadPageTree; | 2878 FX_BOOL m_bTotalLoadPageTree; |
2879 | 2879 |
2880 FX_BOOL m_bCurPageDictLoadOK; | 2880 FX_BOOL m_bCurPageDictLoadOK; |
2881 | 2881 |
2882 CPDF_PageNode m_pageNodes; | 2882 CPDF_PageNode m_pageNodes; |
2883 | 2883 |
2884 std::set<FX_DWORD> m_pageMapCheckState; | 2884 std::set<FX_DWORD> m_pageMapCheckState; |
2885 std::set<FX_DWORD> m_pagesLoadState; | 2885 std::set<FX_DWORD> m_pagesLoadState; |
2886 | 2886 |
2887 nonstd::unique_ptr<CPDF_HintTables> m_pHintTables; | 2887 std::unique_ptr<CPDF_HintTables> m_pHintTables; |
2888 FX_BOOL m_bSupportHintTable; | 2888 FX_BOOL m_bSupportHintTable; |
2889 }; | 2889 }; |
2890 | 2890 |
2891 IPDF_DataAvail::IPDF_DataAvail(IFX_FileAvail* pFileAvail, | 2891 IPDF_DataAvail::IPDF_DataAvail(IFX_FileAvail* pFileAvail, |
2892 IFX_FileRead* pFileRead) | 2892 IFX_FileRead* pFileRead) |
2893 : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {} | 2893 : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {} |
2894 | 2894 |
2895 // static | 2895 // static |
2896 IPDF_DataAvail* IPDF_DataAvail::Create(IFX_FileAvail* pFileAvail, | 2896 IPDF_DataAvail* IPDF_DataAvail::Create(IFX_FileAvail* pFileAvail, |
2897 IFX_FileRead* pFileRead) { | 2897 IFX_FileRead* pFileRead) { |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3592 ? pHintStreamRange->GetElementValue(1)->GetInteger() | 3592 ? pHintStreamRange->GetElementValue(1)->GetInteger() |
3593 : 0; | 3593 : 0; |
3594 if (szHSStart < 0 || szHSLength <= 0) { | 3594 if (szHSStart < 0 || szHSLength <= 0) { |
3595 m_docStatus = PDF_DATAAVAIL_ERROR; | 3595 m_docStatus = PDF_DATAAVAIL_ERROR; |
3596 return FALSE; | 3596 return FALSE; |
3597 } | 3597 } |
3598 if (!IsDataAvail(szHSStart, szHSLength, pHints)) { | 3598 if (!IsDataAvail(szHSStart, szHSLength, pHints)) { |
3599 return FALSE; | 3599 return FALSE; |
3600 } | 3600 } |
3601 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); | 3601 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); |
3602 nonstd::unique_ptr<CPDF_HintTables> pHintTables( | 3602 std::unique_ptr<CPDF_HintTables> pHintTables( |
3603 new CPDF_HintTables(this, pDict)); | 3603 new CPDF_HintTables(this, pDict)); |
3604 nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pHintStream( | 3604 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pHintStream( |
3605 ParseIndirectObjectAt(szHSStart, 0)); | 3605 ParseIndirectObjectAt(szHSStart, 0)); |
3606 CPDF_Stream* pStream = ToStream(pHintStream.get()); | 3606 CPDF_Stream* pStream = ToStream(pHintStream.get()); |
3607 if (pStream && pHintTables->LoadHintStream(pStream)) | 3607 if (pStream && pHintTables->LoadHintStream(pStream)) |
3608 m_pHintTables = std::move(pHintTables); | 3608 m_pHintTables = std::move(pHintTables); |
3609 | 3609 |
3610 m_docStatus = PDF_DATAAVAIL_DONE; | 3610 m_docStatus = PDF_DATAAVAIL_DONE; |
3611 return TRUE; | 3611 return TRUE; |
3612 } | 3612 } |
3613 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt( | 3613 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt( |
3614 FX_FILESIZE pos, | 3614 FX_FILESIZE pos, |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3974 uint8_t* pBuf = buf.GetBuffer(); | 3974 uint8_t* pBuf = buf.GetBuffer(); |
3975 if (!pBuf) { | 3975 if (!pBuf) { |
3976 m_docStatus = PDF_DATAAVAIL_ERROR; | 3976 m_docStatus = PDF_DATAAVAIL_ERROR; |
3977 return FALSE; | 3977 return FALSE; |
3978 } | 3978 } |
3979 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { | 3979 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { |
3980 return FALSE; | 3980 return FALSE; |
3981 } | 3981 } |
3982 ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); | 3982 ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); |
3983 m_syntaxParser.InitParser(file.get(), 0); | 3983 m_syntaxParser.InitParser(file.get(), 0); |
3984 nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pTrailer( | 3984 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pTrailer( |
3985 m_syntaxParser.GetObject(nullptr, 0, 0)); | 3985 m_syntaxParser.GetObject(nullptr, 0, 0)); |
3986 if (!pTrailer) { | 3986 if (!pTrailer) { |
3987 m_Pos += m_syntaxParser.SavePos(); | 3987 m_Pos += m_syntaxParser.SavePos(); |
3988 pHints->AddSegment(m_Pos, iTrailerSize); | 3988 pHints->AddSegment(m_Pos, iTrailerSize); |
3989 return FALSE; | 3989 return FALSE; |
3990 } | 3990 } |
3991 if (!pTrailer->IsDictionary()) | 3991 if (!pTrailer->IsDictionary()) |
3992 return FALSE; | 3992 return FALSE; |
3993 | 3993 |
3994 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); | 3994 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4987 if (!m_pLinearizedDict) | 4987 if (!m_pLinearizedDict) |
4988 return -1; | 4988 return -1; |
4989 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); | 4989 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); |
4990 if (!pRange) | 4990 if (!pRange) |
4991 return -1; | 4991 return -1; |
4992 CPDF_Object* pStreamLen = pRange->GetElementValue(1); | 4992 CPDF_Object* pStreamLen = pRange->GetElementValue(1); |
4993 if (!pStreamLen) | 4993 if (!pStreamLen) |
4994 return -1; | 4994 return -1; |
4995 return pStreamLen->GetInteger(); | 4995 return pStreamLen->GetInteger(); |
4996 } | 4996 } |
OLD | NEW |