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

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

Issue 1671113002: Remove CFX_FileSizeArray. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits. Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « core/include/fxcrt/fx_basic.h ('k') | core/src/fpdfapi/fpdf_parser/parser_int.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "core/include/fpdfapi/fpdf_parser.h" 7 #include "core/include/fpdfapi/fpdf_parser.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 18 matching lines...) Expand all
29 // A limit on the maximum object number in the xref table. Theoretical limits 29 // A limit on the maximum object number in the xref table. Theoretical limits
30 // are higher, but this may be large enough in practice. 30 // are higher, but this may be large enough in practice.
31 const FX_DWORD kMaxObjectNumber = 1048576; 31 const FX_DWORD kMaxObjectNumber = 1048576;
32 32
33 struct SearchTagRecord { 33 struct SearchTagRecord {
34 const char* m_pTag; 34 const char* m_pTag;
35 FX_DWORD m_Len; 35 FX_DWORD m_Len;
36 FX_DWORD m_Offset; 36 FX_DWORD m_Offset;
37 }; 37 };
38 38
39 int CompareFileSize(const void* p1, const void* p2) {
40 return *(FX_FILESIZE*)p1 - *(FX_FILESIZE*)p2;
41 }
42
43 int32_t GetHeaderOffset(IFX_FileRead* pFile) { 39 int32_t GetHeaderOffset(IFX_FileRead* pFile) {
44 const FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025); 40 const FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025);
45 const size_t kBufSize = 4; 41 const size_t kBufSize = 4;
46 uint8_t buf[kBufSize]; 42 uint8_t buf[kBufSize];
47 int32_t offset = 0; 43 int32_t offset = 0;
48 while (offset <= 1024) { 44 while (offset <= 1024) {
49 if (!pFile->ReadBlock(buf, offset, kBufSize)) 45 if (!pFile->ReadBlock(buf, offset, kBufSize))
50 return -1; 46 return -1;
51 47
52 if (*(FX_DWORD*)buf == tag) 48 if (*(FX_DWORD*)buf == tag)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 168 }
173 ReleaseEncryptHandler(); 169 ReleaseEncryptHandler();
174 SetEncryptDictionary(nullptr); 170 SetEncryptDictionary(nullptr);
175 if (m_bOwnFileRead && m_Syntax.m_pFileAccess) { 171 if (m_bOwnFileRead && m_Syntax.m_pFileAccess) {
176 m_Syntax.m_pFileAccess->Release(); 172 m_Syntax.m_pFileAccess->Release();
177 m_Syntax.m_pFileAccess = nullptr; 173 m_Syntax.m_pFileAccess = nullptr;
178 } 174 }
179 m_ObjectStreamMap.clear(); 175 m_ObjectStreamMap.clear();
180 m_ObjCache.clear(); 176 m_ObjCache.clear();
181 177
182 m_SortedOffset.RemoveAll(); 178 m_SortedOffset.clear();
183 m_ObjectInfo.clear(); 179 m_ObjectInfo.clear();
184 int32_t iLen = m_Trailers.GetSize(); 180 int32_t iLen = m_Trailers.GetSize();
185 for (int32_t i = 0; i < iLen; ++i) { 181 for (int32_t i = 0; i < iLen; ++i) {
186 if (CPDF_Dictionary* trailer = m_Trailers.GetAt(i)) 182 if (CPDF_Dictionary* trailer = m_Trailers.GetAt(i))
187 trailer->Release(); 183 trailer->Release();
188 } 184 }
189 m_Trailers.RemoveAll(); 185 m_Trailers.RemoveAll();
190 if (m_pLinearized) { 186 if (m_pLinearized) {
191 m_pLinearized->Release(); 187 m_pLinearized->Release();
192 m_pLinearized = nullptr; 188 m_pLinearized = nullptr;
(...skipping 26 matching lines...) Expand all
219 m_FileVersion += FXSYS_toDecimalDigit(ch); 215 m_FileVersion += FXSYS_toDecimalDigit(ch);
220 216
221 if (m_Syntax.m_FileLen < m_Syntax.m_HeaderOffset + 9) 217 if (m_Syntax.m_FileLen < m_Syntax.m_HeaderOffset + 9)
222 return FORMAT_ERROR; 218 return FORMAT_ERROR;
223 219
224 m_Syntax.RestorePos(m_Syntax.m_FileLen - m_Syntax.m_HeaderOffset - 9); 220 m_Syntax.RestorePos(m_Syntax.m_FileLen - m_Syntax.m_HeaderOffset - 9);
225 m_pDocument = new CPDF_Document(this); 221 m_pDocument = new CPDF_Document(this);
226 222
227 FX_BOOL bXRefRebuilt = FALSE; 223 FX_BOOL bXRefRebuilt = FALSE;
228 if (m_Syntax.SearchWord("startxref", TRUE, FALSE, 4096)) { 224 if (m_Syntax.SearchWord("startxref", TRUE, FALSE, 4096)) {
229 FX_FILESIZE startxref_offset = m_Syntax.SavePos(); 225 m_SortedOffset.insert(m_Syntax.SavePos());
230 void* pResult = FXSYS_bsearch(&startxref_offset, m_SortedOffset.GetData(),
231 m_SortedOffset.GetSize(), sizeof(FX_FILESIZE),
232 CompareFileSize);
233 if (!pResult)
234 m_SortedOffset.Add(startxref_offset);
235
236 m_Syntax.GetKeyword(); 226 m_Syntax.GetKeyword();
237 bool bNumber; 227 bool bNumber;
238 CFX_ByteString xrefpos_str = m_Syntax.GetNextWord(&bNumber); 228 CFX_ByteString xrefpos_str = m_Syntax.GetNextWord(&bNumber);
239 if (!bNumber) 229 if (!bNumber)
240 return FORMAT_ERROR; 230 return FORMAT_ERROR;
241 231
242 m_LastXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); 232 m_LastXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str);
243 if (!LoadAllCrossRefV4(m_LastXRefOffset) && 233 if (!LoadAllCrossRefV4(m_LastXRefOffset) &&
244 !LoadAllCrossRefV5(m_LastXRefOffset)) { 234 !LoadAllCrossRefV5(m_LastXRefOffset)) {
245 if (!RebuildCrossRef()) 235 if (!RebuildCrossRef())
(...skipping 22 matching lines...) Expand all
268 return FORMAT_ERROR; 258 return FORMAT_ERROR;
269 259
270 eRet = SetEncryptHandler(); 260 eRet = SetEncryptHandler();
271 if (eRet != SUCCESS) 261 if (eRet != SUCCESS)
272 return eRet; 262 return eRet;
273 263
274 m_pDocument->LoadDoc(); 264 m_pDocument->LoadDoc();
275 if (!m_pDocument->GetRoot()) 265 if (!m_pDocument->GetRoot())
276 return FORMAT_ERROR; 266 return FORMAT_ERROR;
277 } 267 }
278 FXSYS_qsort(m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
279 sizeof(FX_FILESIZE), CompareFileSize);
280 if (GetRootObjNum() == 0) { 268 if (GetRootObjNum() == 0) {
281 ReleaseEncryptHandler(); 269 ReleaseEncryptHandler();
282 if (!RebuildCrossRef() || GetRootObjNum() == 0) 270 if (!RebuildCrossRef() || GetRootObjNum() == 0)
283 return FORMAT_ERROR; 271 return FORMAT_ERROR;
284 272
285 eRet = SetEncryptHandler(); 273 eRet = SetEncryptHandler();
286 if (eRet != SUCCESS) 274 if (eRet != SUCCESS)
287 return eRet; 275 return eRet;
288 } 276 }
289 if (m_pSecurityHandler && !m_pSecurityHandler->IsMetadataEncrypted()) { 277 if (m_pSecurityHandler && !m_pSecurityHandler->IsMetadataEncrypted()) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 347 }
360 m_pTrailer = LoadTrailerV4(); 348 m_pTrailer = LoadTrailerV4();
361 if (!m_pTrailer) { 349 if (!m_pTrailer) {
362 return FALSE; 350 return FALSE;
363 } 351 }
364 352
365 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size"); 353 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
366 if (xrefsize > 0 && xrefsize <= kMaxXRefSize) 354 if (xrefsize > 0 && xrefsize <= kMaxXRefSize)
367 ShrinkObjectMap(xrefsize); 355 ShrinkObjectMap(xrefsize);
368 356
369 CFX_FileSizeArray CrossRefList; 357 std::vector<FX_FILESIZE> CrossRefList;
370 CFX_FileSizeArray XRefStreamList; 358 std::vector<FX_FILESIZE> XRefStreamList;
371 CrossRefList.Add(xrefpos); 359 std::set<FX_FILESIZE> seen_xrefpos;
372 XRefStreamList.Add(GetDirectInteger(m_pTrailer, "XRefStm")); 360 CrossRefList.push_back(xrefpos);
361 XRefStreamList.push_back(GetDirectInteger(m_pTrailer, "XRefStm"));
362 seen_xrefpos.insert(xrefpos);
373 363
374 std::set<FX_FILESIZE> seen_xrefpos;
375 seen_xrefpos.insert(xrefpos);
376 // When |m_pTrailer| doesn't have Prev entry or Prev entry value is not 364 // When |m_pTrailer| doesn't have Prev entry or Prev entry value is not
377 // numerical, GetDirectInteger() returns 0. Loading will end. 365 // numerical, GetDirectInteger() returns 0. Loading will end.
378 xrefpos = GetDirectInteger(m_pTrailer, "Prev"); 366 xrefpos = GetDirectInteger(m_pTrailer, "Prev");
379 while (xrefpos) { 367 while (xrefpos) {
380 // Check for circular references. 368 // Check for circular references.
381 if (pdfium::ContainsKey(seen_xrefpos, xrefpos)) 369 if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
382 return FALSE; 370 return FALSE;
383 seen_xrefpos.insert(xrefpos); 371 seen_xrefpos.insert(xrefpos);
384 CrossRefList.InsertAt(0, xrefpos); 372 // SLOW ...
Lei Zhang 2016/02/05 19:22:20 You could push_back() and then iterate through the
Tom Sepez 2016/02/05 21:03:02 Nah, the fix is to make it a deque, if I can prove
Lei Zhang 2016/02/05 21:09:56 I was thinking about a deque too, but I realized w
373 CrossRefList.insert(CrossRefList.begin(), xrefpos);
385 LoadCrossRefV4(xrefpos, 0, TRUE); 374 LoadCrossRefV4(xrefpos, 0, TRUE);
386 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( 375 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
387 LoadTrailerV4()); 376 LoadTrailerV4());
388 if (!pDict) 377 if (!pDict)
389 return FALSE; 378 return FALSE;
390 xrefpos = GetDirectInteger(pDict.get(), "Prev"); 379 xrefpos = GetDirectInteger(pDict.get(), "Prev");
391 380 // SLOW ...
392 XRefStreamList.InsertAt(0, pDict->GetIntegerBy("XRefStm")); 381 XRefStreamList.insert(XRefStreamList.begin(),
382 pDict->GetIntegerBy("XRefStm"));
393 m_Trailers.Add(pDict.release()); 383 m_Trailers.Add(pDict.release());
394 } 384 }
395 for (int32_t i = 0; i < CrossRefList.GetSize(); i++) { 385 for (size_t i = 0; i < CrossRefList.size(); ++i) {
396 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE)) 386 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE))
397 return FALSE; 387 return FALSE;
398 } 388 }
399 return TRUE; 389 return TRUE;
400 } 390 }
401 FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos, 391 FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
402 FX_DWORD dwObjCount) { 392 FX_DWORD dwObjCount) {
403 if (!LoadLinearizedCrossRefV4(xrefpos, dwObjCount)) { 393 if (!LoadLinearizedCrossRefV4(xrefpos, dwObjCount)) {
404 return FALSE; 394 return FALSE;
405 } 395 }
406 m_pTrailer = LoadTrailerV4(); 396 m_pTrailer = LoadTrailerV4();
407 if (!m_pTrailer) { 397 if (!m_pTrailer) {
408 return FALSE; 398 return FALSE;
409 } 399 }
410 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size"); 400 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
411 if (xrefsize == 0) { 401 if (xrefsize == 0) {
412 return FALSE; 402 return FALSE;
413 } 403 }
414 CFX_FileSizeArray CrossRefList, XRefStreamList;
415 CrossRefList.Add(xrefpos);
416 XRefStreamList.Add(GetDirectInteger(m_pTrailer, "XRefStm"));
417 404
405 std::vector<FX_FILESIZE> CrossRefList;
406 std::vector<FX_FILESIZE> XRefStreamList;
418 std::set<FX_FILESIZE> seen_xrefpos; 407 std::set<FX_FILESIZE> seen_xrefpos;
408 CrossRefList.push_back(xrefpos);
409 XRefStreamList.push_back(GetDirectInteger(m_pTrailer, "XRefStm"));
419 seen_xrefpos.insert(xrefpos); 410 seen_xrefpos.insert(xrefpos);
411
420 xrefpos = GetDirectInteger(m_pTrailer, "Prev"); 412 xrefpos = GetDirectInteger(m_pTrailer, "Prev");
421 while (xrefpos) { 413 while (xrefpos) {
422 // Check for circular references. 414 // Check for circular references.
423 if (pdfium::ContainsKey(seen_xrefpos, xrefpos)) 415 if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
424 return FALSE; 416 return FALSE;
425 seen_xrefpos.insert(xrefpos); 417 seen_xrefpos.insert(xrefpos);
426 CrossRefList.InsertAt(0, xrefpos); 418 // SLOW ...
419 CrossRefList.insert(CrossRefList.begin(), xrefpos);
427 LoadCrossRefV4(xrefpos, 0, TRUE); 420 LoadCrossRefV4(xrefpos, 0, TRUE);
428 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( 421 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
429 LoadTrailerV4()); 422 LoadTrailerV4());
430 if (!pDict) { 423 if (!pDict) {
431 return FALSE; 424 return FALSE;
432 } 425 }
433 xrefpos = GetDirectInteger(pDict.get(), "Prev"); 426 xrefpos = GetDirectInteger(pDict.get(), "Prev");
434 427 // SLOW ...
435 XRefStreamList.InsertAt(0, pDict->GetIntegerBy("XRefStm")); 428 XRefStreamList.insert(XRefStreamList.begin(),
429 pDict->GetIntegerBy("XRefStm"));
436 m_Trailers.Add(pDict.release()); 430 m_Trailers.Add(pDict.release());
437 } 431 }
438 for (int32_t i = 1; i < CrossRefList.GetSize(); i++) 432 for (size_t i = 1; i < CrossRefList.size(); ++i)
439 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE)) { 433 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE)) {
440 return FALSE; 434 return FALSE;
441 } 435 }
442 return TRUE; 436 return TRUE;
443 } 437 }
444 FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, 438 FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
445 FX_DWORD dwObjCount) { 439 FX_DWORD dwObjCount) {
446 FX_FILESIZE dwStartPos = pos - m_Syntax.m_HeaderOffset; 440 FX_FILESIZE dwStartPos = pos - m_Syntax.m_HeaderOffset;
447 m_Syntax.RestorePos(dwStartPos); 441 m_Syntax.RestorePos(dwStartPos);
448 void* pResult = 442 m_SortedOffset.insert(pos);
449 FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
450 sizeof(FX_FILESIZE), CompareFileSize);
451 if (!pResult) {
452 m_SortedOffset.Add(pos);
453 }
454 FX_DWORD start_objnum = 0; 443 FX_DWORD start_objnum = 0;
455 FX_DWORD count = dwObjCount; 444 FX_DWORD count = dwObjCount;
456 FX_FILESIZE SavedPos = m_Syntax.SavePos(); 445 FX_FILESIZE SavedPos = m_Syntax.SavePos();
457 const int32_t recordsize = 20; 446 const int32_t recordsize = 20;
458 std::vector<char> buf(1024 * recordsize + 1); 447 std::vector<char> buf(1024 * recordsize + 1);
459 buf[1024 * recordsize] = '\0'; 448 buf[1024 * recordsize] = '\0';
460 int32_t nBlocks = count / 1024 + 1; 449 int32_t nBlocks = count / 1024 + 1;
461 for (int32_t block = 0; block < nBlocks; block++) { 450 for (int32_t block = 0; block < nBlocks; block++) {
462 int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024; 451 int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024;
463 FX_DWORD dwReadSize = block_size * recordsize; 452 FX_DWORD dwReadSize = block_size * recordsize;
(...skipping 18 matching lines...) Expand all
482 return FALSE; 471 return FALSE;
483 } 472 }
484 } 473 }
485 m_ObjectInfo[objnum].pos = offset; 474 m_ObjectInfo[objnum].pos = offset;
486 int32_t version = FXSYS_atoi(pEntry + 11); 475 int32_t version = FXSYS_atoi(pEntry + 11);
487 if (version >= 1) { 476 if (version >= 1) {
488 m_bVersionUpdated = TRUE; 477 m_bVersionUpdated = TRUE;
489 } 478 }
490 m_ObjectInfo[objnum].gennum = version; 479 m_ObjectInfo[objnum].gennum = version;
491 if (m_ObjectInfo[objnum].pos < m_Syntax.m_FileLen) { 480 if (m_ObjectInfo[objnum].pos < m_Syntax.m_FileLen) {
492 void* pResult = FXSYS_bsearch( 481 m_SortedOffset.insert(m_ObjectInfo[objnum].pos);
493 &m_ObjectInfo[objnum].pos, m_SortedOffset.GetData(),
494 m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), CompareFileSize);
495 if (!pResult) {
496 m_SortedOffset.Add(m_ObjectInfo[objnum].pos);
497 }
498 } 482 }
499 m_ObjectInfo[objnum].type = 1; 483 m_ObjectInfo[objnum].type = 1;
500 } 484 }
501 } 485 }
502 } 486 }
503 m_Syntax.RestorePos(SavedPos + count * recordsize); 487 m_Syntax.RestorePos(SavedPos + count * recordsize);
504 return TRUE; 488 return TRUE;
505 } 489 }
506 490
507 bool CPDF_Parser::FindPosInOffsets(FX_FILESIZE pos) const {
508 return FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
509 sizeof(FX_FILESIZE), CompareFileSize);
510 }
511
512 bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, 491 bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
513 FX_FILESIZE streampos, 492 FX_FILESIZE streampos,
514 FX_BOOL bSkip) { 493 FX_BOOL bSkip) {
515 m_Syntax.RestorePos(pos); 494 m_Syntax.RestorePos(pos);
516 if (m_Syntax.GetKeyword() != "xref") 495 if (m_Syntax.GetKeyword() != "xref")
517 return false; 496 return false;
518 497
519 if (!FindPosInOffsets(pos)) 498 m_SortedOffset.insert(pos);
520 m_SortedOffset.Add(pos); 499 if (streampos)
521 500 m_SortedOffset.insert(streampos);
522 if (streampos && !FindPosInOffsets(streampos))
523 m_SortedOffset.Add(streampos);
524 501
525 while (1) { 502 while (1) {
526 FX_FILESIZE SavedPos = m_Syntax.SavePos(); 503 FX_FILESIZE SavedPos = m_Syntax.SavePos();
527 bool bIsNumber; 504 bool bIsNumber;
528 CFX_ByteString word = m_Syntax.GetNextWord(&bIsNumber); 505 CFX_ByteString word = m_Syntax.GetNextWord(&bIsNumber);
529 if (word.IsEmpty()) 506 if (word.IsEmpty())
530 return false; 507 return false;
531 508
532 if (!bIsNumber) { 509 if (!bIsNumber) {
533 m_Syntax.RestorePos(SavedPos); 510 m_Syntax.RestorePos(SavedPos);
(...skipping 29 matching lines...) Expand all
563 if (!std::isdigit(pEntry[c])) 540 if (!std::isdigit(pEntry[c]))
564 return false; 541 return false;
565 } 542 }
566 } 543 }
567 m_ObjectInfo[objnum].pos = offset; 544 m_ObjectInfo[objnum].pos = offset;
568 int32_t version = FXSYS_atoi(pEntry + 11); 545 int32_t version = FXSYS_atoi(pEntry + 11);
569 if (version >= 1) { 546 if (version >= 1) {
570 m_bVersionUpdated = TRUE; 547 m_bVersionUpdated = TRUE;
571 } 548 }
572 m_ObjectInfo[objnum].gennum = version; 549 m_ObjectInfo[objnum].gennum = version;
573 if (m_ObjectInfo[objnum].pos < m_Syntax.m_FileLen && 550 if (m_ObjectInfo[objnum].pos < m_Syntax.m_FileLen) {
574 !FindPosInOffsets(m_ObjectInfo[objnum].pos)) { 551 m_SortedOffset.insert(m_ObjectInfo[objnum].pos);
575 m_SortedOffset.Add(m_ObjectInfo[objnum].pos);
576 } 552 }
577 m_ObjectInfo[objnum].type = 1; 553 m_ObjectInfo[objnum].type = 1;
578 } 554 }
579 } 555 }
580 } 556 }
581 } 557 }
582 m_Syntax.RestorePos(SavedPos + count * recordsize); 558 m_Syntax.RestorePos(SavedPos + count * recordsize);
583 } 559 }
584 return !streampos || LoadCrossRefV5(&streampos, FALSE); 560 return !streampos || LoadCrossRefV5(&streampos, FALSE);
585 } 561 }
(...skipping 13 matching lines...) Expand all
599 return FALSE; 575 return FALSE;
600 } 576 }
601 } 577 }
602 m_ObjectStreamMap.clear(); 578 m_ObjectStreamMap.clear();
603 m_bXRefStream = TRUE; 579 m_bXRefStream = TRUE;
604 return TRUE; 580 return TRUE;
605 } 581 }
606 582
607 FX_BOOL CPDF_Parser::RebuildCrossRef() { 583 FX_BOOL CPDF_Parser::RebuildCrossRef() {
608 m_ObjectInfo.clear(); 584 m_ObjectInfo.clear();
609 m_SortedOffset.RemoveAll(); 585 m_SortedOffset.clear();
610 if (m_pTrailer) { 586 if (m_pTrailer) {
611 m_pTrailer->Release(); 587 m_pTrailer->Release();
612 m_pTrailer = NULL; 588 m_pTrailer = NULL;
613 } 589 }
614 int32_t status = 0; 590 int32_t status = 0;
615 int32_t inside_index = 0; 591 int32_t inside_index = 0;
616 FX_DWORD objnum = 0; 592 FX_DWORD objnum = 0;
617 FX_DWORD gennum = 0; 593 FX_DWORD gennum = 0;
618 int32_t depth = 0; 594 int32_t depth = 0;
619 const FX_DWORD kBufferSize = 4096; 595 const FX_DWORD kBufferSize = 4096;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 inside_index++; 736 inside_index++;
761 } 737 }
762 break; 738 break;
763 case 3: 739 case 3:
764 if (PDFCharIsWhitespace(byte) || PDFCharIsDelimiter(byte)) { 740 if (PDFCharIsWhitespace(byte) || PDFCharIsDelimiter(byte)) {
765 if (objnum > 0x1000000) { 741 if (objnum > 0x1000000) {
766 status = 0; 742 status = 0;
767 break; 743 break;
768 } 744 }
769 FX_FILESIZE obj_pos = start_pos - m_Syntax.m_HeaderOffset; 745 FX_FILESIZE obj_pos = start_pos - m_Syntax.m_HeaderOffset;
746 m_SortedOffset.insert(obj_pos);
770 last_obj = start_pos; 747 last_obj = start_pos;
771 void* pResult =
772 FXSYS_bsearch(&obj_pos, m_SortedOffset.GetData(),
773 m_SortedOffset.GetSize(), sizeof(FX_FILESIZE),
774 CompareFileSize);
775 if (!pResult) {
776 m_SortedOffset.Add(obj_pos);
777 }
778 FX_FILESIZE obj_end = 0; 748 FX_FILESIZE obj_end = 0;
779 CPDF_Object* pObject = ParseIndirectObjectAtByStrict( 749 CPDF_Object* pObject = ParseIndirectObjectAtByStrict(
780 m_pDocument, obj_pos, objnum, &obj_end); 750 m_pDocument, obj_pos, objnum, &obj_end);
781 if (CPDF_Stream* pStream = ToStream(pObject)) { 751 if (CPDF_Stream* pStream = ToStream(pObject)) {
782 if (CPDF_Dictionary* pDict = pStream->GetDict()) { 752 if (CPDF_Dictionary* pDict = pStream->GetDict()) {
783 if ((pDict->KeyExist("Type")) && 753 if ((pDict->KeyExist("Type")) &&
784 (pDict->GetStringBy("Type") == "XRef" && 754 (pDict->GetStringBy("Type") == "XRef" &&
785 pDict->KeyExist("Size"))) { 755 pDict->KeyExist("Size"))) {
786 CPDF_Object* pRoot = pDict->GetElement("Root"); 756 CPDF_Object* pRoot = pDict->GetElement("Root");
787 if (pRoot && pRoot->GetDict() && 757 if (pRoot && pRoot->GetDict() &&
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 // If the position has not changed at all in a loop iteration, then break 937 // If the position has not changed at all in a loop iteration, then break
968 // out to prevent infinite looping. 938 // out to prevent infinite looping.
969 if (pos == saved_pos) 939 if (pos == saved_pos)
970 break; 940 break;
971 } 941 }
972 if (last_xref != -1 && last_xref > last_obj) { 942 if (last_xref != -1 && last_xref > last_obj) {
973 last_trailer = last_xref; 943 last_trailer = last_xref;
974 } else if (last_trailer == -1 || last_xref < last_obj) { 944 } else if (last_trailer == -1 || last_xref < last_obj) {
975 last_trailer = m_Syntax.m_FileLen; 945 last_trailer = m_Syntax.m_FileLen;
976 } 946 }
977 FX_FILESIZE offset = last_trailer - m_Syntax.m_HeaderOffset; 947 m_SortedOffset.insert(last_trailer - m_Syntax.m_HeaderOffset);
978 void* pResult =
979 FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
980 sizeof(FX_FILESIZE), CompareFileSize);
981 if (!pResult) {
982 m_SortedOffset.Add(offset);
983 }
984 return m_pTrailer && !m_ObjectInfo.empty(); 948 return m_pTrailer && !m_ObjectInfo.empty();
985 } 949 }
986 950
987 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { 951 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
988 CPDF_Object* pObject = ParseIndirectObjectAt(m_pDocument, *pos, 0); 952 CPDF_Object* pObject = ParseIndirectObjectAt(m_pDocument, *pos, 0);
989 if (!pObject) 953 if (!pObject)
990 return FALSE; 954 return FALSE;
991 if (m_pDocument) { 955 if (m_pDocument) {
992 FX_BOOL bInserted = FALSE; 956 FX_BOOL bInserted = FALSE;
993 CPDF_Dictionary* pDict = m_pDocument->GetRoot(); 957 CPDF_Dictionary* pDict = m_pDocument->GetRoot();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 for (FX_DWORD j = 0; j < count; j++) { 1049 for (FX_DWORD j = 0; j < count; j++) {
1086 int32_t type = 1; 1050 int32_t type = 1;
1087 const uint8_t* entrystart = segstart + j * totalWidth; 1051 const uint8_t* entrystart = segstart + j * totalWidth;
1088 if (WidthArray[0]) { 1052 if (WidthArray[0]) {
1089 type = GetVarInt(entrystart, WidthArray[0]); 1053 type = GetVarInt(entrystart, WidthArray[0]);
1090 } 1054 }
1091 if (GetObjectType(startnum + j) == 255) { 1055 if (GetObjectType(startnum + j) == 255) {
1092 FX_FILESIZE offset = 1056 FX_FILESIZE offset =
1093 GetVarInt(entrystart + WidthArray[0], WidthArray[1]); 1057 GetVarInt(entrystart + WidthArray[0], WidthArray[1]);
1094 m_ObjectInfo[startnum + j].pos = offset; 1058 m_ObjectInfo[startnum + j].pos = offset;
1095 void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), 1059 m_SortedOffset.insert(offset);
1096 m_SortedOffset.GetSize(),
1097 sizeof(FX_FILESIZE), CompareFileSize);
1098 if (!pResult) {
1099 m_SortedOffset.Add(offset);
1100 }
1101 continue; 1060 continue;
1102 } 1061 }
1103 if (GetObjectType(startnum + j)) { 1062 if (GetObjectType(startnum + j)) {
1104 continue; 1063 continue;
1105 } 1064 }
1106 m_ObjectInfo[startnum + j].type = type; 1065 m_ObjectInfo[startnum + j].type = type;
1107 if (type == 0) { 1066 if (type == 0) {
1108 m_ObjectInfo[startnum + j].pos = 0; 1067 m_ObjectInfo[startnum + j].pos = 0;
1109 } else { 1068 } else {
1110 FX_FILESIZE offset = 1069 FX_FILESIZE offset =
1111 GetVarInt(entrystart + WidthArray[0], WidthArray[1]); 1070 GetVarInt(entrystart + WidthArray[0], WidthArray[1]);
1112 m_ObjectInfo[startnum + j].pos = offset; 1071 m_ObjectInfo[startnum + j].pos = offset;
1113 if (type == 1) { 1072 if (type == 1) {
1114 void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), 1073 m_SortedOffset.insert(offset);
1115 m_SortedOffset.GetSize(),
1116 sizeof(FX_FILESIZE), CompareFileSize);
1117 if (!pResult) {
1118 m_SortedOffset.Add(offset);
1119 }
1120 } else { 1074 } else {
1121 if (offset < 0 || !IsValidObjectNumber(offset)) { 1075 if (offset < 0 || !IsValidObjectNumber(offset)) {
1122 pStream->Release(); 1076 pStream->Release();
1123 return FALSE; 1077 return FALSE;
1124 } 1078 }
1125 m_ObjectInfo[offset].type = 255; 1079 m_ObjectInfo[offset].type = 255;
1126 } 1080 }
1127 } 1081 }
1128 } 1082 }
1129 segindex += count; 1083 segindex += count;
(...skipping 24 matching lines...) Expand all
1154 } 1108 }
1155 FX_BOOL CPDF_Parser::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) { 1109 FX_BOOL CPDF_Parser::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) {
1156 bForm = FALSE; 1110 bForm = FALSE;
1157 if (!IsValidObjectNumber(objnum)) 1111 if (!IsValidObjectNumber(objnum))
1158 return TRUE; 1112 return TRUE;
1159 if (GetObjectType(objnum) == 0) 1113 if (GetObjectType(objnum) == 0)
1160 return TRUE; 1114 return TRUE;
1161 if (GetObjectType(objnum) == 2) 1115 if (GetObjectType(objnum) == 2)
1162 return TRUE; 1116 return TRUE;
1163 FX_FILESIZE pos = m_ObjectInfo[objnum].pos; 1117 FX_FILESIZE pos = m_ObjectInfo[objnum].pos;
1164 void* pResult = 1118 auto it = m_SortedOffset.find(pos);
1165 FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), 1119 if (it == m_SortedOffset.end())
1166 sizeof(FX_FILESIZE), CompareFileSize);
1167 if (!pResult) {
1168 return TRUE; 1120 return TRUE;
1169 } 1121 if (++it == m_SortedOffset.end())
1170 if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() ==
1171 m_SortedOffset.GetSize() - 1) {
1172 return FALSE; 1122 return FALSE;
1173 } 1123 FX_FILESIZE size = *it - pos;
1174 FX_FILESIZE size = ((FX_FILESIZE*)pResult)[1] - pos;
1175 FX_FILESIZE SavedPos = m_Syntax.SavePos(); 1124 FX_FILESIZE SavedPos = m_Syntax.SavePos();
1176 m_Syntax.RestorePos(pos); 1125 m_Syntax.RestorePos(pos);
1177 const char kFormStream[] = "/Form\0stream"; 1126 const char kFormStream[] = "/Form\0stream";
1178 const CFX_ByteStringC kFormStreamStr(kFormStream, sizeof(kFormStream) - 1); 1127 const CFX_ByteStringC kFormStreamStr(kFormStream, sizeof(kFormStream) - 1);
1179 bForm = m_Syntax.SearchMultiWord(kFormStreamStr, TRUE, size) == 0; 1128 bForm = m_Syntax.SearchMultiWord(kFormStreamStr, TRUE, size) == 0;
1180 m_Syntax.RestorePos(SavedPos); 1129 m_Syntax.RestorePos(SavedPos);
1181 return TRUE; 1130 return TRUE;
1182 } 1131 }
1183 1132
1184 CPDF_Object* CPDF_Parser::ParseIndirectObject( 1133 CPDF_Object* CPDF_Parser::ParseIndirectObject(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 return pStreamAcc; 1195 return pStreamAcc;
1247 } 1196 }
1248 1197
1249 FX_FILESIZE CPDF_Parser::GetObjectSize(FX_DWORD objnum) const { 1198 FX_FILESIZE CPDF_Parser::GetObjectSize(FX_DWORD objnum) const {
1250 if (!IsValidObjectNumber(objnum)) 1199 if (!IsValidObjectNumber(objnum))
1251 return 0; 1200 return 0;
1252 1201
1253 if (GetObjectType(objnum) == 2) 1202 if (GetObjectType(objnum) == 2)
1254 objnum = GetObjectPositionOrZero(objnum); 1203 objnum = GetObjectPositionOrZero(objnum);
1255 1204
1256 if (GetObjectType(objnum) == 1 || GetObjectType(objnum) == 255) { 1205 if (GetObjectType(objnum) != 1 && GetObjectType(objnum) != 255)
1257 FX_FILESIZE offset = GetObjectPositionOrZero(objnum); 1206 return 0;
1258 if (offset == 0)
1259 return 0;
1260 1207
1261 FX_FILESIZE* pResult = static_cast<FX_FILESIZE*>(FXSYS_bsearch( 1208 FX_FILESIZE offset = GetObjectPositionOrZero(objnum);
1262 &offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), 1209 if (offset == 0)
1263 sizeof(FX_FILESIZE), CompareFileSize)); 1210 return 0;
1264 if (!pResult)
1265 return 0;
1266 1211
1267 if (pResult - m_SortedOffset.GetData() == m_SortedOffset.GetSize() - 1) 1212 auto it = m_SortedOffset.find(offset);
1268 return 0; 1213 if (it == m_SortedOffset.end() || ++it == m_SortedOffset.end())
1214 return 0;
1269 1215
1270 return pResult[1] - offset; 1216 return *it - offset;
1271 }
1272 return 0;
1273 } 1217 }
1274 1218
1275 void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, 1219 void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum,
1276 uint8_t*& pBuffer, 1220 uint8_t*& pBuffer,
1277 FX_DWORD& size) { 1221 FX_DWORD& size) {
1278 pBuffer = NULL; 1222 pBuffer = NULL;
1279 size = 0; 1223 size = 0;
1280 if (!IsValidObjectNumber(objnum)) 1224 if (!IsValidObjectNumber(objnum))
1281 return; 1225 return;
1282 1226
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 } 1278 }
1335 word = m_Syntax.GetNextWord(&bIsNumber); 1279 word = m_Syntax.GetNextWord(&bIsNumber);
1336 if (!bIsNumber) { 1280 if (!bIsNumber) {
1337 m_Syntax.RestorePos(SavedPos); 1281 m_Syntax.RestorePos(SavedPos);
1338 return; 1282 return;
1339 } 1283 }
1340 if (m_Syntax.GetKeyword() != "obj") { 1284 if (m_Syntax.GetKeyword() != "obj") {
1341 m_Syntax.RestorePos(SavedPos); 1285 m_Syntax.RestorePos(SavedPos);
1342 return; 1286 return;
1343 } 1287 }
1344 void* pResult = 1288 auto it = m_SortedOffset.find(pos);
1345 FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), 1289 if (it == m_SortedOffset.end() || ++it == m_SortedOffset.end()) {
1346 sizeof(FX_FILESIZE), CompareFileSize);
1347 if (!pResult) {
1348 m_Syntax.RestorePos(SavedPos); 1290 m_Syntax.RestorePos(SavedPos);
1349 return; 1291 return;
1350 } 1292 }
1351 FX_FILESIZE nextoff = ((FX_FILESIZE*)pResult)[1]; 1293 FX_FILESIZE nextoff = *it;
1352 FX_BOOL bNextOffValid = FALSE; 1294 FX_BOOL bNextOffValid = FALSE;
1353 if (nextoff != pos) { 1295 if (nextoff != pos) {
1354 m_Syntax.RestorePos(nextoff); 1296 m_Syntax.RestorePos(nextoff);
1355 word = m_Syntax.GetNextWord(&bIsNumber); 1297 word = m_Syntax.GetNextWord(&bIsNumber);
1356 if (word == "xref") { 1298 if (word == "xref") {
1357 bNextOffValid = TRUE; 1299 bNextOffValid = TRUE;
1358 } else if (bIsNumber) { 1300 } else if (bIsNumber) {
1359 word = m_Syntax.GetNextWord(&bIsNumber); 1301 word = m_Syntax.GetNextWord(&bIsNumber);
1360 if (bIsNumber && m_Syntax.GetKeyword() == "obj") { 1302 if (bIsNumber && m_Syntax.GetKeyword() == "obj") {
1361 bNextOffValid = TRUE; 1303 bNextOffValid = TRUE;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 } 1529 }
1588 eRet = SetEncryptHandler(); 1530 eRet = SetEncryptHandler();
1589 if (eRet != SUCCESS) { 1531 if (eRet != SUCCESS) {
1590 return eRet; 1532 return eRet;
1591 } 1533 }
1592 m_pDocument->LoadAsynDoc(m_pLinearized->GetDict()); 1534 m_pDocument->LoadAsynDoc(m_pLinearized->GetDict());
1593 if (!m_pDocument->GetRoot()) { 1535 if (!m_pDocument->GetRoot()) {
1594 return FORMAT_ERROR; 1536 return FORMAT_ERROR;
1595 } 1537 }
1596 } 1538 }
1597 FXSYS_qsort(m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
1598 sizeof(FX_FILESIZE), CompareFileSize);
1599 if (GetRootObjNum() == 0) { 1539 if (GetRootObjNum() == 0) {
1600 ReleaseEncryptHandler(); 1540 ReleaseEncryptHandler();
1601 if (!RebuildCrossRef() || GetRootObjNum() == 0) 1541 if (!RebuildCrossRef() || GetRootObjNum() == 0)
1602 return FORMAT_ERROR; 1542 return FORMAT_ERROR;
1603 1543
1604 eRet = SetEncryptHandler(); 1544 eRet = SetEncryptHandler();
1605 if (eRet != SUCCESS) { 1545 if (eRet != SUCCESS) {
1606 return eRet; 1546 return eRet;
1607 } 1547 }
1608 } 1548 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 m_LastXRefOffset += dwCount; 1596 m_LastXRefOffset += dwCount;
1657 m_ObjectStreamMap.clear(); 1597 m_ObjectStreamMap.clear();
1658 m_ObjCache.clear(); 1598 m_ObjCache.clear();
1659 1599
1660 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1600 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1661 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1601 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1662 m_LastXRefOffset = 0; 1602 m_LastXRefOffset = 0;
1663 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; 1603 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum;
1664 return FORMAT_ERROR; 1604 return FORMAT_ERROR;
1665 } 1605 }
1666 FXSYS_qsort(m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
1667 sizeof(FX_FILESIZE), CompareFileSize);
1668 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; 1606 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum;
1669 return SUCCESS; 1607 return SUCCESS;
1670 } 1608 }
1671 1609
1672 // static 1610 // static
1673 int CPDF_SyntaxParser::s_CurrentRecursionDepth = 0; 1611 int CPDF_SyntaxParser::s_CurrentRecursionDepth = 0;
1674 1612
1675 CPDF_SyntaxParser::CPDF_SyntaxParser() { 1613 CPDF_SyntaxParser::CPDF_SyntaxParser() {
1676 m_pFileAccess = NULL; 1614 m_pFileAccess = NULL;
1677 m_pFileBuf = NULL; 1615 m_pFileBuf = NULL;
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
2657 CPDF_PageNode* pPageNode, 2595 CPDF_PageNode* pPageNode,
2658 IFX_DownloadHints* pHints); 2596 IFX_DownloadHints* pHints);
2659 FX_BOOL CheckPageCount(IFX_DownloadHints* pHints); 2597 FX_BOOL CheckPageCount(IFX_DownloadHints* pHints);
2660 bool IsFirstCheck(int iPage); 2598 bool IsFirstCheck(int iPage);
2661 void ResetFirstCheck(int iPage); 2599 void ResetFirstCheck(int iPage);
2662 FX_BOOL IsDataAvail(FX_FILESIZE offset, 2600 FX_BOOL IsDataAvail(FX_FILESIZE offset,
2663 FX_DWORD size, 2601 FX_DWORD size,
2664 IFX_DownloadHints* pHints); 2602 IFX_DownloadHints* pHints);
2665 2603
2666 CPDF_Parser m_parser; 2604 CPDF_Parser m_parser;
2667
2668 CPDF_SyntaxParser m_syntaxParser; 2605 CPDF_SyntaxParser m_syntaxParser;
2669
2670 CPDF_Object* m_pRoot; 2606 CPDF_Object* m_pRoot;
2671
2672 FX_DWORD m_dwRootObjNum; 2607 FX_DWORD m_dwRootObjNum;
2673
2674 FX_DWORD m_dwInfoObjNum; 2608 FX_DWORD m_dwInfoObjNum;
2675
2676 CPDF_Object* m_pLinearized; 2609 CPDF_Object* m_pLinearized;
2677
2678 CPDF_Object* m_pTrailer; 2610 CPDF_Object* m_pTrailer;
2679
2680 FX_BOOL m_bDocAvail; 2611 FX_BOOL m_bDocAvail;
2681
2682 FX_FILESIZE m_dwHeaderOffset; 2612 FX_FILESIZE m_dwHeaderOffset;
2683
2684 FX_FILESIZE m_dwLastXRefOffset; 2613 FX_FILESIZE m_dwLastXRefOffset;
2685
2686 FX_FILESIZE m_dwXRefOffset; 2614 FX_FILESIZE m_dwXRefOffset;
2687
2688 FX_FILESIZE m_dwTrailerOffset; 2615 FX_FILESIZE m_dwTrailerOffset;
2689
2690 FX_FILESIZE m_dwCurrentOffset; 2616 FX_FILESIZE m_dwCurrentOffset;
2691
2692 PDF_DATAAVAIL_STATUS m_docStatus; 2617 PDF_DATAAVAIL_STATUS m_docStatus;
2693
2694 FX_FILESIZE m_dwFileLen; 2618 FX_FILESIZE m_dwFileLen;
2695
2696 CPDF_Document* m_pDocument; 2619 CPDF_Document* m_pDocument;
2697
2698 std::set<FX_DWORD> m_ObjectSet; 2620 std::set<FX_DWORD> m_ObjectSet;
2699
2700 CFX_ArrayTemplate<CPDF_Object*> m_objs_array; 2621 CFX_ArrayTemplate<CPDF_Object*> m_objs_array;
2701
2702 FX_FILESIZE m_Pos; 2622 FX_FILESIZE m_Pos;
2703
2704 FX_FILESIZE m_bufferOffset; 2623 FX_FILESIZE m_bufferOffset;
2705
2706 FX_DWORD m_bufferSize; 2624 FX_DWORD m_bufferSize;
2707
2708 CFX_ByteString m_WordBuf; 2625 CFX_ByteString m_WordBuf;
2709
2710 uint8_t m_bufferData[512]; 2626 uint8_t m_bufferData[512];
2711 2627 std::vector<FX_FILESIZE> m_CrossOffset;
2712 CFX_FileSizeArray m_CrossOffset;
2713
2714 CFX_DWordArray m_XRefStreamList; 2628 CFX_DWordArray m_XRefStreamList;
2715
2716 CFX_DWordArray m_PageObjList; 2629 CFX_DWordArray m_PageObjList;
2717
2718 FX_DWORD m_PagesObjNum; 2630 FX_DWORD m_PagesObjNum;
2719
2720 FX_BOOL m_bLinearized; 2631 FX_BOOL m_bLinearized;
2721
2722 FX_DWORD m_dwFirstPageNo; 2632 FX_DWORD m_dwFirstPageNo;
2723
2724 FX_BOOL m_bLinearedDataOK; 2633 FX_BOOL m_bLinearedDataOK;
2725
2726 FX_BOOL m_bMainXRefLoadTried; 2634 FX_BOOL m_bMainXRefLoadTried;
2727
2728 FX_BOOL m_bMainXRefLoadedOK; 2635 FX_BOOL m_bMainXRefLoadedOK;
2729
2730 FX_BOOL m_bPagesTreeLoad; 2636 FX_BOOL m_bPagesTreeLoad;
2731
2732 FX_BOOL m_bPagesLoad; 2637 FX_BOOL m_bPagesLoad;
2733
2734 CPDF_Parser* m_pCurrentParser; 2638 CPDF_Parser* m_pCurrentParser;
2735
2736 FX_FILESIZE m_dwCurrentXRefSteam; 2639 FX_FILESIZE m_dwCurrentXRefSteam;
2737
2738 FX_BOOL m_bAnnotsLoad; 2640 FX_BOOL m_bAnnotsLoad;
2739
2740 FX_BOOL m_bHaveAcroForm; 2641 FX_BOOL m_bHaveAcroForm;
2741
2742 FX_DWORD m_dwAcroFormObjNum; 2642 FX_DWORD m_dwAcroFormObjNum;
2743
2744 FX_BOOL m_bAcroFormLoad; 2643 FX_BOOL m_bAcroFormLoad;
2745
2746 CPDF_Object* m_pAcroForm; 2644 CPDF_Object* m_pAcroForm;
2747
2748 CFX_ArrayTemplate<CPDF_Object*> m_arrayAcroforms; 2645 CFX_ArrayTemplate<CPDF_Object*> m_arrayAcroforms;
2749
2750 CPDF_Dictionary* m_pPageDict; 2646 CPDF_Dictionary* m_pPageDict;
2751
2752 CPDF_Object* m_pPageResource; 2647 CPDF_Object* m_pPageResource;
2753
2754 FX_BOOL m_bNeedDownLoadResource; 2648 FX_BOOL m_bNeedDownLoadResource;
2755
2756 FX_BOOL m_bPageLoadedOK; 2649 FX_BOOL m_bPageLoadedOK;
2757
2758 FX_BOOL m_bLinearizedFormParamLoad; 2650 FX_BOOL m_bLinearizedFormParamLoad;
2759
2760 CFX_ArrayTemplate<CPDF_Object*> m_PagesArray; 2651 CFX_ArrayTemplate<CPDF_Object*> m_PagesArray;
2761
2762 FX_DWORD m_dwEncryptObjNum; 2652 FX_DWORD m_dwEncryptObjNum;
2763
2764 FX_FILESIZE m_dwPrevXRefOffset; 2653 FX_FILESIZE m_dwPrevXRefOffset;
2765
2766 FX_BOOL m_bTotalLoadPageTree; 2654 FX_BOOL m_bTotalLoadPageTree;
2767
2768 FX_BOOL m_bCurPageDictLoadOK; 2655 FX_BOOL m_bCurPageDictLoadOK;
2769
2770 CPDF_PageNode m_pageNodes; 2656 CPDF_PageNode m_pageNodes;
2771
2772 std::set<FX_DWORD> m_pageMapCheckState; 2657 std::set<FX_DWORD> m_pageMapCheckState;
2773 std::set<FX_DWORD> m_pagesLoadState; 2658 std::set<FX_DWORD> m_pagesLoadState;
2774
2775 std::unique_ptr<CPDF_HintTables> m_pHintTables; 2659 std::unique_ptr<CPDF_HintTables> m_pHintTables;
2776 FX_BOOL m_bSupportHintTable; 2660 FX_BOOL m_bSupportHintTable;
2777 }; 2661 };
2778 2662
2779 IPDF_DataAvail::IPDF_DataAvail(IFX_FileAvail* pFileAvail, 2663 IPDF_DataAvail::IPDF_DataAvail(IFX_FileAvail* pFileAvail,
2780 IFX_FileRead* pFileRead) 2664 IFX_FileRead* pFileRead)
2781 : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {} 2665 : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {}
2782 2666
2783 // static 2667 // static
2784 IPDF_DataAvail* IPDF_DataAvail::Create(IFX_FileAvail* pFileAvail, 2668 IPDF_DataAvail* IPDF_DataAvail::Create(IFX_FileAvail* pFileAvail,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 m_pDocument = pDoc; 2742 m_pDocument = pDoc;
2859 } 2743 }
2860 FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) { 2744 FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) {
2861 CPDF_Parser* pParser = m_pDocument->GetParser(); 2745 CPDF_Parser* pParser = m_pDocument->GetParser();
2862 if (!pParser || !pParser->IsValidObjectNumber(objnum)) 2746 if (!pParser || !pParser->IsValidObjectNumber(objnum))
2863 return 0; 2747 return 0;
2864 2748
2865 if (pParser->GetObjectType(objnum) == 2) 2749 if (pParser->GetObjectType(objnum) == 2)
2866 objnum = pParser->GetObjectPositionOrZero(objnum); 2750 objnum = pParser->GetObjectPositionOrZero(objnum);
2867 2751
2868 if (pParser->GetObjectType(objnum) == 1 || 2752 if (pParser->GetObjectType(objnum) != 1 &&
2869 pParser->GetObjectType(objnum) == 255) { 2753 pParser->GetObjectType(objnum) != 255) {
2870 offset = pParser->GetObjectPositionOrZero(objnum); 2754 return 0;
2871 if (offset == 0) {
2872 return 0;
2873 }
2874 void* pResult = FXSYS_bsearch(&offset, pParser->m_SortedOffset.GetData(),
2875 pParser->m_SortedOffset.GetSize(),
2876 sizeof(FX_FILESIZE), CompareFileSize);
2877 if (!pResult) {
2878 return 0;
2879 }
2880 if ((FX_FILESIZE*)pResult -
2881 (FX_FILESIZE*)pParser->m_SortedOffset.GetData() ==
2882 pParser->m_SortedOffset.GetSize() - 1) {
2883 return 0;
2884 }
2885 return (FX_DWORD)(((FX_FILESIZE*)pResult)[1] - offset);
2886 } 2755 }
2887 return 0; 2756
2757 offset = pParser->GetObjectPositionOrZero(objnum);
2758 if (offset == 0)
2759 return 0;
2760
2761 auto it = pParser->m_SortedOffset.find(offset);
2762 if (it == pParser->m_SortedOffset.end() ||
2763 ++it == pParser->m_SortedOffset.end()) {
2764 return 0;
2765 }
2766 return *it - offset;
2888 } 2767 }
2889 FX_BOOL CPDF_DataAvail::IsObjectsAvail( 2768 FX_BOOL CPDF_DataAvail::IsObjectsAvail(
2890 CFX_ArrayTemplate<CPDF_Object*>& obj_array, 2769 CFX_ArrayTemplate<CPDF_Object*>& obj_array,
2891 FX_BOOL bParsePage, 2770 FX_BOOL bParsePage,
2892 IFX_DownloadHints* pHints, 2771 IFX_DownloadHints* pHints,
2893 CFX_ArrayTemplate<CPDF_Object*>& ret_array) { 2772 CFX_ArrayTemplate<CPDF_Object*>& ret_array) {
2894 if (!obj_array.GetSize()) { 2773 if (!obj_array.GetSize()) {
2895 return TRUE; 2774 return TRUE;
2896 } 2775 }
2897 FX_DWORD count = 0; 2776 FX_DWORD count = 0;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 return FALSE; 2979 return FALSE;
3101 } 2980 }
3102 FX_BOOL CPDF_DataAvail::LoadAllXref(IFX_DownloadHints* pHints) { 2981 FX_BOOL CPDF_DataAvail::LoadAllXref(IFX_DownloadHints* pHints) {
3103 m_parser.m_Syntax.InitParser(m_pFileRead, (FX_DWORD)m_dwHeaderOffset); 2982 m_parser.m_Syntax.InitParser(m_pFileRead, (FX_DWORD)m_dwHeaderOffset);
3104 m_parser.m_bOwnFileRead = false; 2983 m_parser.m_bOwnFileRead = false;
3105 if (!m_parser.LoadAllCrossRefV4(m_dwLastXRefOffset) && 2984 if (!m_parser.LoadAllCrossRefV4(m_dwLastXRefOffset) &&
3106 !m_parser.LoadAllCrossRefV5(m_dwLastXRefOffset)) { 2985 !m_parser.LoadAllCrossRefV5(m_dwLastXRefOffset)) {
3107 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; 2986 m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
3108 return FALSE; 2987 return FALSE;
3109 } 2988 }
3110 FXSYS_qsort(m_parser.m_SortedOffset.GetData(),
3111 m_parser.m_SortedOffset.GetSize(), sizeof(FX_FILESIZE),
3112 CompareFileSize);
3113 m_dwRootObjNum = m_parser.GetRootObjNum(); 2989 m_dwRootObjNum = m_parser.GetRootObjNum();
3114 m_dwInfoObjNum = m_parser.GetInfoObjNum(); 2990 m_dwInfoObjNum = m_parser.GetInfoObjNum();
3115 m_pCurrentParser = &m_parser; 2991 m_pCurrentParser = &m_parser;
3116 m_docStatus = PDF_DATAAVAIL_ROOT; 2992 m_docStatus = PDF_DATAAVAIL_ROOT;
3117 return TRUE; 2993 return TRUE;
3118 } 2994 }
3119 CPDF_Object* CPDF_DataAvail::GetObject(FX_DWORD objnum, 2995 CPDF_Object* CPDF_DataAvail::GetObject(FX_DWORD objnum,
3120 IFX_DownloadHints* pHints, 2996 IFX_DownloadHints* pHints,
3121 FX_BOOL* pExistInFile) { 2997 FX_BOOL* pExistInFile) {
3122 CPDF_Object* pRet = nullptr; 2998 CPDF_Object* pRet = nullptr;
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
3803 } 3679 }
3804 FX_BOOL CPDF_DataAvail::CheckCrossRef(IFX_DownloadHints* pHints) { 3680 FX_BOOL CPDF_DataAvail::CheckCrossRef(IFX_DownloadHints* pHints) {
3805 int32_t iSize = 0; 3681 int32_t iSize = 0;
3806 CFX_ByteString token; 3682 CFX_ByteString token;
3807 if (!GetNextToken(token)) { 3683 if (!GetNextToken(token)) {
3808 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); 3684 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512);
3809 pHints->AddSegment(m_Pos, iSize); 3685 pHints->AddSegment(m_Pos, iSize);
3810 return FALSE; 3686 return FALSE;
3811 } 3687 }
3812 if (token == "xref") { 3688 if (token == "xref") {
3813 m_CrossOffset.InsertAt(0, m_dwXRefOffset); 3689 // SLOW ...
3690 m_CrossOffset.insert(m_CrossOffset.begin(), m_dwXRefOffset);
Lei Zhang 2016/02/05 19:22:20 BTW, we insert into |m_crossoffset| but never read
Tom Sepez 2016/02/05 21:03:02 Removed.
3814 while (1) { 3691 while (1) {
3815 if (!GetNextToken(token)) { 3692 if (!GetNextToken(token)) {
3816 iSize = 3693 iSize =
3817 (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); 3694 (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512);
3818 pHints->AddSegment(m_Pos, iSize); 3695 pHints->AddSegment(m_Pos, iSize);
3819 m_docStatus = PDF_DATAAVAIL_CROSSREF_ITEM; 3696 m_docStatus = PDF_DATAAVAIL_CROSSREF_ITEM;
3820 return FALSE; 3697 return FALSE;
3821 } 3698 }
3822 if (token == "trailer") { 3699 if (token == "trailer") {
3823 m_dwTrailerOffset = m_Pos; 3700 m_dwTrailerOffset = m_Pos;
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
4479 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) { 4356 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) {
4480 delete m_childNode[i]; 4357 delete m_childNode[i];
4481 } 4358 }
4482 m_childNode.RemoveAll(); 4359 m_childNode.RemoveAll();
4483 } 4360 }
4484 CPDF_HintTables::~CPDF_HintTables() { 4361 CPDF_HintTables::~CPDF_HintTables() {
4485 m_dwDeltaNObjsArray.RemoveAll(); 4362 m_dwDeltaNObjsArray.RemoveAll();
4486 m_dwNSharedObjsArray.RemoveAll(); 4363 m_dwNSharedObjsArray.RemoveAll();
4487 m_dwSharedObjNumArray.RemoveAll(); 4364 m_dwSharedObjNumArray.RemoveAll();
4488 m_dwIdentifierArray.RemoveAll(); 4365 m_dwIdentifierArray.RemoveAll();
4489 m_szPageOffsetArray.RemoveAll();
4490 m_szSharedObjOffsetArray.RemoveAll();
4491 } 4366 }
4492 FX_DWORD CPDF_HintTables::GetItemLength(int index, 4367 FX_DWORD CPDF_HintTables::GetItemLength(
4493 const CFX_FileSizeArray& szArray) { 4368 int index,
4494 if (index < 0 || szArray.GetSize() < 2 || index > szArray.GetSize() - 2 || 4369 const std::vector<FX_FILESIZE>& szArray) {
4495 szArray[index] > szArray[index + 1]) 4370 if (index < 0 || szArray.size() < 2 || index > szArray.size() - 2 ||
4371 szArray[index] > szArray[index + 1]) {
4496 return 0; 4372 return 0;
4373 }
4497 return szArray[index + 1] - szArray[index]; 4374 return szArray[index + 1] - szArray[index];
4498 } 4375 }
4499 FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) { 4376 FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
4500 if (!hStream || hStream->IsEOF()) 4377 if (!hStream || hStream->IsEOF())
4501 return FALSE; 4378 return FALSE;
4502 int nStreamOffset = ReadPrimaryHintStreamOffset(); 4379 int nStreamOffset = ReadPrimaryHintStreamOffset();
4503 int nStreamLen = ReadPrimaryHintStreamLength(); 4380 int nStreamLen = ReadPrimaryHintStreamLength();
4504 if (nStreamOffset < 0 || nStreamLen < 1) 4381 if (nStreamOffset < 0 || nStreamLen < 1)
4505 return FALSE; 4382 return FALSE;
4506 4383
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4576 dwPageLenArray.Add(safePageLen.ValueOrDie()); 4453 dwPageLenArray.Add(safePageLen.ValueOrDie());
4577 } 4454 }
4578 CPDF_Object* pOffsetE = m_pLinearizedDict->GetElementValue("E"); 4455 CPDF_Object* pOffsetE = m_pLinearizedDict->GetElementValue("E");
4579 int nOffsetE = pOffsetE ? pOffsetE->GetInteger() : -1; 4456 int nOffsetE = pOffsetE ? pOffsetE->GetInteger() : -1;
4580 if (nOffsetE < 0) 4457 if (nOffsetE < 0)
4581 return FALSE; 4458 return FALSE;
4582 CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetElementValue("P"); 4459 CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetElementValue("P");
4583 int nFirstPageNum = pFirstPageNum ? pFirstPageNum->GetInteger() : 0; 4460 int nFirstPageNum = pFirstPageNum ? pFirstPageNum->GetInteger() : 0;
4584 for (int i = 0; i < nPages; ++i) { 4461 for (int i = 0; i < nPages; ++i) {
4585 if (i == nFirstPageNum) { 4462 if (i == nFirstPageNum) {
4586 m_szPageOffsetArray.Add(m_szFirstPageObjOffset); 4463 m_szPageOffsetArray.push_back(m_szFirstPageObjOffset);
4587 } else if (i == nFirstPageNum + 1) { 4464 } else if (i == nFirstPageNum + 1) {
4588 if (i == 1) { 4465 if (i == 1) {
4589 m_szPageOffsetArray.Add(nOffsetE); 4466 m_szPageOffsetArray.push_back(nOffsetE);
4590 } else { 4467 } else {
4591 m_szPageOffsetArray.Add(m_szPageOffsetArray[i - 2] + 4468 m_szPageOffsetArray.push_back(m_szPageOffsetArray[i - 2] +
4592 dwPageLenArray[i - 2]); 4469 dwPageLenArray[i - 2]);
4593 } 4470 }
4594 } else { 4471 } else {
4595 if (i == 0) { 4472 if (i == 0) {
4596 m_szPageOffsetArray.Add(nOffsetE); 4473 m_szPageOffsetArray.push_back(nOffsetE);
4597 } else { 4474 } else {
4598 m_szPageOffsetArray.Add(m_szPageOffsetArray[i - 1] + 4475 m_szPageOffsetArray.push_back(m_szPageOffsetArray[i - 1] +
4599 dwPageLenArray[i - 1]); 4476 dwPageLenArray[i - 1]);
4600 } 4477 }
4601 } 4478 }
4602 } 4479 }
4603 if (nPages > 0) { 4480 if (nPages > 0) {
4604 m_szPageOffsetArray.Add(m_szPageOffsetArray[nPages - 1] + 4481 m_szPageOffsetArray.push_back(m_szPageOffsetArray[nPages - 1] +
4605 dwPageLenArray[nPages - 1]); 4482 dwPageLenArray[nPages - 1]);
4606 } 4483 }
4607 hStream->ByteAlign(); 4484 hStream->ByteAlign();
4608 4485
4609 // number of shared objects 4486 // number of shared objects
4610 required_bits = dwSharedObjBits; 4487 required_bits = dwSharedObjBits;
4611 required_bits *= pdfium::base::checked_cast<FX_DWORD>(nPages); 4488 required_bits *= pdfium::base::checked_cast<FX_DWORD>(nPages);
4612 if (!CanReadFromBitStream(hStream, required_bits)) 4489 if (!CanReadFromBitStream(hStream, required_bits))
4613 return FALSE; 4490 return FALSE;
4614 for (int i = 0; i < nPages; i++) { 4491 for (int i = 0; i < nPages; i++) {
4615 m_dwNSharedObjsArray.Add(hStream->GetBits(dwSharedObjBits)); 4492 m_dwNSharedObjsArray.Add(hStream->GetBits(dwSharedObjBits));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
4697 for (int i = 0; i < dwSharedObjTotal; ++i) { 4574 for (int i = 0; i < dwSharedObjTotal; ++i) {
4698 dwPrevObjLen = dwCurObjLen; 4575 dwPrevObjLen = dwCurObjLen;
4699 FX_SAFE_DWORD safeObjLen = hStream->GetBits(dwDeltaGroupLen); 4576 FX_SAFE_DWORD safeObjLen = hStream->GetBits(dwDeltaGroupLen);
4700 safeObjLen += dwGroupLeastLen; 4577 safeObjLen += dwGroupLeastLen;
4701 if (!safeObjLen.IsValid()) 4578 if (!safeObjLen.IsValid())
4702 return FALSE; 4579 return FALSE;
4703 dwCurObjLen = safeObjLen.ValueOrDie(); 4580 dwCurObjLen = safeObjLen.ValueOrDie();
4704 if (i < m_nFirstPageSharedObjs) { 4581 if (i < m_nFirstPageSharedObjs) {
4705 m_dwSharedObjNumArray.Add(nFirstPageObjNum + i); 4582 m_dwSharedObjNumArray.Add(nFirstPageObjNum + i);
4706 if (i == 0) 4583 if (i == 0)
4707 m_szSharedObjOffsetArray.Add(m_szFirstPageObjOffset); 4584 m_szSharedObjOffsetArray.push_back(m_szFirstPageObjOffset);
4708 } else { 4585 } else {
4709 FX_SAFE_DWORD safeObjNum = dwFirstSharedObjNum; 4586 FX_SAFE_DWORD safeObjNum = dwFirstSharedObjNum;
4710 safeObjNum += i - m_nFirstPageSharedObjs; 4587 safeObjNum += i - m_nFirstPageSharedObjs;
4711 if (!safeObjNum.IsValid()) 4588 if (!safeObjNum.IsValid())
4712 return FALSE; 4589 return FALSE;
4713 m_dwSharedObjNumArray.Add(safeObjNum.ValueOrDie()); 4590 m_dwSharedObjNumArray.Add(safeObjNum.ValueOrDie());
4714 if (i == m_nFirstPageSharedObjs) 4591 if (i == m_nFirstPageSharedObjs)
4715 m_szSharedObjOffsetArray.Add( 4592 m_szSharedObjOffsetArray.push_back(
4716 pdfium::base::checked_cast<int32_t>(dwFirstSharedObjLoc)); 4593 pdfium::base::checked_cast<int32_t>(dwFirstSharedObjLoc));
4717 } 4594 }
4718 if (i != 0 && i != m_nFirstPageSharedObjs) { 4595 if (i != 0 && i != m_nFirstPageSharedObjs) {
4719 FX_SAFE_INT32 safeLoc = pdfium::base::checked_cast<int32_t>(dwPrevObjLen); 4596 FX_SAFE_INT32 safeLoc = pdfium::base::checked_cast<int32_t>(dwPrevObjLen);
4720 safeLoc += m_szSharedObjOffsetArray[i - 1]; 4597 safeLoc += m_szSharedObjOffsetArray[i - 1];
4721 if (!safeLoc.IsValid()) 4598 if (!safeLoc.IsValid())
4722 return FALSE; 4599 return FALSE;
4723 m_szSharedObjOffsetArray.Add(safeLoc.ValueOrDie()); 4600 m_szSharedObjOffsetArray.push_back(safeLoc.ValueOrDie());
4724 } 4601 }
4725 } 4602 }
4726 if (dwSharedObjTotal > 0) { 4603 if (dwSharedObjTotal > 0) {
4727 FX_SAFE_INT32 safeLoc = pdfium::base::checked_cast<int32_t>(dwCurObjLen); 4604 FX_SAFE_INT32 safeLoc = pdfium::base::checked_cast<int32_t>(dwCurObjLen);
4728 safeLoc += m_szSharedObjOffsetArray[dwSharedObjTotal - 1]; 4605 safeLoc += m_szSharedObjOffsetArray[dwSharedObjTotal - 1];
4729 if (!safeLoc.IsValid()) 4606 if (!safeLoc.IsValid())
4730 return FALSE; 4607 return FALSE;
4731 m_szSharedObjOffsetArray.Add(safeLoc.ValueOrDie()); 4608 m_szSharedObjOffsetArray.push_back(safeLoc.ValueOrDie());
4732 } 4609 }
4733 hStream->ByteAlign(); 4610 hStream->ByteAlign();
4734 if (hStream->BitsRemaining() < dwSharedObjTotal) 4611 if (hStream->BitsRemaining() < dwSharedObjTotal)
4735 return FALSE; 4612 return FALSE;
4736 hStream->SkipBits(dwSharedObjTotal); 4613 hStream->SkipBits(dwSharedObjTotal);
4737 hStream->ByteAlign(); 4614 hStream->ByteAlign();
4738 return TRUE; 4615 return TRUE;
4739 } 4616 }
4740 FX_BOOL CPDF_HintTables::GetPagePos(int index, 4617 FX_BOOL CPDF_HintTables::GetPagePos(int index,
4741 FX_FILESIZE& szPageStartPos, 4618 FX_FILESIZE& szPageStartPos,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
4852 if (!m_pLinearizedDict) 4729 if (!m_pLinearizedDict)
4853 return -1; 4730 return -1;
4854 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); 4731 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H");
4855 if (!pRange) 4732 if (!pRange)
4856 return -1; 4733 return -1;
4857 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 4734 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
4858 if (!pStreamLen) 4735 if (!pStreamLen)
4859 return -1; 4736 return -1;
4860 return pStreamLen->GetInteger(); 4737 return pStreamLen->GetInteger();
4861 } 4738 }
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_basic.h ('k') | core/src/fpdfapi/fpdf_parser/parser_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698