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

Side by Side Diff: core/fpdfapi/parser/cpdf_syntax_parser.cpp

Issue 2479303002: Use unique_ptr return from CPDF_Parser::ParseIndirectObject() (Closed)
Patch Set: Work around android Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/fpdfapi/parser/cpdf_syntax_parser.h" 7 #include "core/fpdfapi/parser/cpdf_syntax_parser.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "core/fpdfapi/cpdf_modulemgr.h" 11 #include "core/fpdfapi/cpdf_modulemgr.h"
12 #include "core/fpdfapi/parser/cpdf_array.h" 12 #include "core/fpdfapi/parser/cpdf_array.h"
13 #include "core/fpdfapi/parser/cpdf_boolean.h" 13 #include "core/fpdfapi/parser/cpdf_boolean.h"
14 #include "core/fpdfapi/parser/cpdf_crypto_handler.h" 14 #include "core/fpdfapi/parser/cpdf_crypto_handler.h"
15 #include "core/fpdfapi/parser/cpdf_dictionary.h" 15 #include "core/fpdfapi/parser/cpdf_dictionary.h"
16 #include "core/fpdfapi/parser/cpdf_name.h" 16 #include "core/fpdfapi/parser/cpdf_name.h"
17 #include "core/fpdfapi/parser/cpdf_null.h" 17 #include "core/fpdfapi/parser/cpdf_null.h"
18 #include "core/fpdfapi/parser/cpdf_number.h" 18 #include "core/fpdfapi/parser/cpdf_number.h"
19 #include "core/fpdfapi/parser/cpdf_reference.h" 19 #include "core/fpdfapi/parser/cpdf_reference.h"
20 #include "core/fpdfapi/parser/cpdf_stream.h" 20 #include "core/fpdfapi/parser/cpdf_stream.h"
21 #include "core/fpdfapi/parser/cpdf_string.h" 21 #include "core/fpdfapi/parser/cpdf_string.h"
22 #include "core/fpdfapi/parser/fpdf_parser_decode.h" 22 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
23 #include "core/fpdfapi/parser/fpdf_parser_utility.h" 23 #include "core/fpdfapi/parser/fpdf_parser_utility.h"
24 #include "core/fxcrt/fx_ext.h" 24 #include "core/fxcrt/fx_ext.h"
25 #include "third_party/base/numerics/safe_math.h" 25 #include "third_party/base/numerics/safe_math.h"
26 #include "third_party/base/ptr_util.h"
26 27
27 namespace { 28 namespace {
28 29
29 enum class ReadStatus { Normal, Backslash, Octal, FinishOctal, CarriageReturn }; 30 enum class ReadStatus { Normal, Backslash, Octal, FinishOctal, CarriageReturn };
30 31
31 } // namespace 32 } // namespace
32 33
33 // static 34 // static
34 int CPDF_SyntaxParser::s_CurrentRecursionDepth = 0; 35 int CPDF_SyntaxParser::s_CurrentRecursionDepth = 0;
35 36
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 356
356 CFX_ByteString CPDF_SyntaxParser::GetNextWord(bool* bIsNumber) { 357 CFX_ByteString CPDF_SyntaxParser::GetNextWord(bool* bIsNumber) {
357 GetNextWordInternal(bIsNumber); 358 GetNextWordInternal(bIsNumber);
358 return CFX_ByteString((const FX_CHAR*)m_WordBuffer, m_WordSize); 359 return CFX_ByteString((const FX_CHAR*)m_WordBuffer, m_WordSize);
359 } 360 }
360 361
361 CFX_ByteString CPDF_SyntaxParser::GetKeyword() { 362 CFX_ByteString CPDF_SyntaxParser::GetKeyword() {
362 return GetNextWord(nullptr); 363 return GetNextWord(nullptr);
363 } 364 }
364 365
365 CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, 366 std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObject(
366 uint32_t objnum, 367 CPDF_IndirectObjectHolder* pObjList,
367 uint32_t gennum, 368 uint32_t objnum,
368 bool bDecrypt) { 369 uint32_t gennum,
370 bool bDecrypt) {
369 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); 371 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
370 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) 372 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth)
371 return nullptr; 373 return nullptr;
372 374
373 FX_FILESIZE SavedObjPos = m_Pos; 375 FX_FILESIZE SavedObjPos = m_Pos;
374 bool bIsNumber; 376 bool bIsNumber;
375 CFX_ByteString word = GetNextWord(&bIsNumber); 377 CFX_ByteString word = GetNextWord(&bIsNumber);
376 if (word.GetLength() == 0) 378 if (word.GetLength() == 0)
377 return nullptr; 379 return nullptr;
378 380
379 if (bIsNumber) { 381 if (bIsNumber) {
380 FX_FILESIZE SavedPos = m_Pos; 382 FX_FILESIZE SavedPos = m_Pos;
381 CFX_ByteString nextword = GetNextWord(&bIsNumber); 383 CFX_ByteString nextword = GetNextWord(&bIsNumber);
382 if (bIsNumber) { 384 if (bIsNumber) {
383 CFX_ByteString nextword2 = GetNextWord(nullptr); 385 CFX_ByteString nextword2 = GetNextWord(nullptr);
384 if (nextword2 == "R") 386 if (nextword2 == "R") {
385 return new CPDF_Reference(pObjList, FXSYS_atoui(word.c_str())); 387 return pdfium::MakeUnique<CPDF_Reference>(pObjList,
388 FXSYS_atoui(word.c_str()));
389 }
386 } 390 }
387 m_Pos = SavedPos; 391 m_Pos = SavedPos;
388 return new CPDF_Number(word.AsStringC()); 392 return pdfium::MakeUnique<CPDF_Number>(word.AsStringC());
389 } 393 }
390 394
391 if (word == "true" || word == "false") 395 if (word == "true" || word == "false")
392 return new CPDF_Boolean(word == "true"); 396 return pdfium::MakeUnique<CPDF_Boolean>(word == "true");
393 397
394 if (word == "null") 398 if (word == "null")
395 return new CPDF_Null; 399 return pdfium::MakeUnique<CPDF_Null>();
396 400
397 if (word == "(") { 401 if (word == "(") {
398 CFX_ByteString str = ReadString(); 402 CFX_ByteString str = ReadString();
399 if (m_pCryptoHandler && bDecrypt) 403 if (m_pCryptoHandler && bDecrypt)
400 m_pCryptoHandler->Decrypt(objnum, gennum, str); 404 m_pCryptoHandler->Decrypt(objnum, gennum, str);
401 return new CPDF_String(MaybeIntern(str), false); 405 return pdfium::MakeUnique<CPDF_String>(MaybeIntern(str), false);
402 } 406 }
403
404 if (word == "<") { 407 if (word == "<") {
405 CFX_ByteString str = ReadHexString(); 408 CFX_ByteString str = ReadHexString();
406 if (m_pCryptoHandler && bDecrypt) 409 if (m_pCryptoHandler && bDecrypt)
407 m_pCryptoHandler->Decrypt(objnum, gennum, str); 410 m_pCryptoHandler->Decrypt(objnum, gennum, str);
408 return new CPDF_String(MaybeIntern(str), true); 411 return pdfium::MakeUnique<CPDF_String>(MaybeIntern(str), true);
409 } 412 }
410
411 if (word == "[") { 413 if (word == "[") {
412 CPDF_Array* pArray = new CPDF_Array; 414 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>();
413 while (CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, true)) 415 while (std::unique_ptr<CPDF_Object> pObj =
414 pArray->Add(pObj); 416 GetObject(pObjList, objnum, gennum, true)) {
415 417 pArray->Add(pObj.release());
416 return pArray; 418 }
419 return std::move(pArray);
417 } 420 }
418
419 if (word[0] == '/') { 421 if (word[0] == '/') {
420 return new CPDF_Name(MaybeIntern( 422 return pdfium::MakeUnique<CPDF_Name>(MaybeIntern(
421 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)))); 423 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))));
422 } 424 }
423
424 if (word == "<<") { 425 if (word == "<<") {
425 int32_t nKeys = 0; 426 int32_t nKeys = 0;
426 FX_FILESIZE dwSignValuePos = 0; 427 FX_FILESIZE dwSignValuePos = 0;
427 428 std::unique_ptr<CPDF_Dictionary> pDict =
428 std::unique_ptr<CPDF_Dictionary> pDict(new CPDF_Dictionary(m_pPool)); 429 pdfium::MakeUnique<CPDF_Dictionary>(m_pPool);
429 while (1) { 430 while (1) {
430 CFX_ByteString key = GetNextWord(nullptr); 431 CFX_ByteString key = GetNextWord(nullptr);
431 if (key.IsEmpty()) 432 if (key.IsEmpty())
432 return nullptr; 433 return nullptr;
433 434
434 FX_FILESIZE SavedPos = m_Pos - key.GetLength(); 435 FX_FILESIZE SavedPos = m_Pos - key.GetLength();
435 if (key == ">>") 436 if (key == ">>")
436 break; 437 break;
437 438
438 if (key == "endobj") { 439 if (key == "endobj") {
439 m_Pos = SavedPos; 440 m_Pos = SavedPos;
440 break; 441 break;
441 } 442 }
442
443 if (key[0] != '/') 443 if (key[0] != '/')
444 continue; 444 continue;
445 445
446 ++nKeys; 446 ++nKeys;
447 key = PDF_NameDecode(key); 447 key = PDF_NameDecode(key);
448 if (key.IsEmpty()) 448 if (key.IsEmpty())
449 continue; 449 continue;
450 450
451 if (key == "/Contents") 451 if (key == "/Contents")
452 dwSignValuePos = m_Pos; 452 dwSignValuePos = m_Pos;
453 453
454 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, true); 454 std::unique_ptr<CPDF_Object> pObj =
455 GetObject(pObjList, objnum, gennum, true);
455 if (!pObj) 456 if (!pObj)
456 continue; 457 continue;
457 458
458 CFX_ByteString keyNoSlash(key.raw_str() + 1, key.GetLength() - 1); 459 CFX_ByteString keyNoSlash(key.raw_str() + 1, key.GetLength() - 1);
459 pDict->SetFor(keyNoSlash, pObj); 460 pDict->SetFor(keyNoSlash, pObj.release());
460 } 461 }
461 462
462 // Only when this is a signature dictionary and has contents, we reset the 463 // Only when this is a signature dictionary and has contents, we reset the
463 // contents to the un-decrypted form. 464 // contents to the un-decrypted form.
464 if (pDict->IsSignatureDict() && dwSignValuePos) { 465 if (pDict->IsSignatureDict() && dwSignValuePos) {
465 CFX_AutoRestorer<FX_FILESIZE> save_pos(&m_Pos); 466 CFX_AutoRestorer<FX_FILESIZE> save_pos(&m_Pos);
466 m_Pos = dwSignValuePos; 467 m_Pos = dwSignValuePos;
467 pDict->SetFor("Contents", GetObject(pObjList, objnum, gennum, false)); 468 pDict->SetFor("Contents",
469 GetObject(pObjList, objnum, gennum, false).release());
468 } 470 }
469 471
470 FX_FILESIZE SavedPos = m_Pos; 472 FX_FILESIZE SavedPos = m_Pos;
471 CFX_ByteString nextword = GetNextWord(nullptr); 473 CFX_ByteString nextword = GetNextWord(nullptr);
472 if (nextword != "stream") { 474 if (nextword != "stream") {
473 m_Pos = SavedPos; 475 m_Pos = SavedPos;
474 return pDict.release(); 476 return std::move(pDict);
475 } 477 }
476 return ReadStream(pDict.release(), objnum, gennum); 478 return ReadStream(pDict.release(), objnum, gennum);
477 } 479 }
478 480
479 if (word == ">>") 481 if (word == ">>")
480 m_Pos = SavedObjPos; 482 m_Pos = SavedObjPos;
481 483
482 return nullptr; 484 return nullptr;
483 } 485 }
484 486
485 CPDF_Object* CPDF_SyntaxParser::GetObjectForStrict( 487 std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectForStrict(
486 CPDF_IndirectObjectHolder* pObjList, 488 CPDF_IndirectObjectHolder* pObjList,
487 uint32_t objnum, 489 uint32_t objnum,
488 uint32_t gennum) { 490 uint32_t gennum) {
489 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); 491 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
490 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) 492 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth)
491 return nullptr; 493 return nullptr;
492 494
493 FX_FILESIZE SavedObjPos = m_Pos; 495 FX_FILESIZE SavedObjPos = m_Pos;
494 bool bIsNumber; 496 bool bIsNumber;
495 CFX_ByteString word = GetNextWord(&bIsNumber); 497 CFX_ByteString word = GetNextWord(&bIsNumber);
496 if (word.GetLength() == 0) 498 if (word.GetLength() == 0)
497 return nullptr; 499 return nullptr;
498 500
499 if (bIsNumber) { 501 if (bIsNumber) {
500 FX_FILESIZE SavedPos = m_Pos; 502 FX_FILESIZE SavedPos = m_Pos;
501 CFX_ByteString nextword = GetNextWord(&bIsNumber); 503 CFX_ByteString nextword = GetNextWord(&bIsNumber);
502 if (bIsNumber) { 504 if (bIsNumber) {
503 CFX_ByteString nextword2 = GetNextWord(nullptr); 505 CFX_ByteString nextword2 = GetNextWord(nullptr);
504 if (nextword2 == "R") 506 if (nextword2 == "R") {
505 return new CPDF_Reference(pObjList, FXSYS_atoui(word.c_str())); 507 return pdfium::MakeUnique<CPDF_Reference>(pObjList,
508 FXSYS_atoui(word.c_str()));
509 }
506 } 510 }
507 m_Pos = SavedPos; 511 m_Pos = SavedPos;
508 return new CPDF_Number(word.AsStringC()); 512 return pdfium::MakeUnique<CPDF_Number>(word.AsStringC());
509 } 513 }
510 514
511 if (word == "true" || word == "false") 515 if (word == "true" || word == "false")
512 return new CPDF_Boolean(word == "true"); 516 return pdfium::MakeUnique<CPDF_Boolean>(word == "true");
513 517
514 if (word == "null") 518 if (word == "null")
515 return new CPDF_Null; 519 return pdfium::MakeUnique<CPDF_Null>();
516 520
517 if (word == "(") { 521 if (word == "(") {
518 CFX_ByteString str = ReadString(); 522 CFX_ByteString str = ReadString();
519 if (m_pCryptoHandler) 523 if (m_pCryptoHandler)
520 m_pCryptoHandler->Decrypt(objnum, gennum, str); 524 m_pCryptoHandler->Decrypt(objnum, gennum, str);
521 return new CPDF_String(MaybeIntern(str), false); 525 return pdfium::MakeUnique<CPDF_String>(MaybeIntern(str), false);
522 } 526 }
523
524 if (word == "<") { 527 if (word == "<") {
525 CFX_ByteString str = ReadHexString(); 528 CFX_ByteString str = ReadHexString();
526 if (m_pCryptoHandler) 529 if (m_pCryptoHandler)
527 m_pCryptoHandler->Decrypt(objnum, gennum, str); 530 m_pCryptoHandler->Decrypt(objnum, gennum, str);
528 return new CPDF_String(MaybeIntern(str), true); 531 return pdfium::MakeUnique<CPDF_String>(MaybeIntern(str), true);
529 } 532 }
530
531 if (word == "[") { 533 if (word == "[") {
532 std::unique_ptr<CPDF_Array> pArray(new CPDF_Array); 534 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>();
533 while (CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, true)) 535 while (std::unique_ptr<CPDF_Object> pObj =
534 pArray->Add(pObj); 536 GetObject(pObjList, objnum, gennum, true)) {
535 537 pArray->Add(pObj.release());
536 return m_WordBuffer[0] == ']' ? pArray.release() : nullptr; 538 }
539 return m_WordBuffer[0] == ']' ? std::move(pArray) : nullptr;
537 } 540 }
538
539 if (word[0] == '/') { 541 if (word[0] == '/') {
540 return new CPDF_Name(MaybeIntern( 542 return pdfium::MakeUnique<CPDF_Name>(MaybeIntern(
541 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)))); 543 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))));
542 } 544 }
543
544 if (word == "<<") { 545 if (word == "<<") {
545 std::unique_ptr<CPDF_Dictionary> pDict(new CPDF_Dictionary(m_pPool)); 546 std::unique_ptr<CPDF_Dictionary> pDict =
547 pdfium::MakeUnique<CPDF_Dictionary>(m_pPool);
546 while (1) { 548 while (1) {
547 FX_FILESIZE SavedPos = m_Pos; 549 FX_FILESIZE SavedPos = m_Pos;
548 CFX_ByteString key = GetNextWord(nullptr); 550 CFX_ByteString key = GetNextWord(nullptr);
549 if (key.IsEmpty()) 551 if (key.IsEmpty())
550 return nullptr; 552 return nullptr;
551 553
552 if (key == ">>") 554 if (key == ">>")
553 break; 555 break;
554 556
555 if (key == "endobj") { 557 if (key == "endobj") {
556 m_Pos = SavedPos; 558 m_Pos = SavedPos;
557 break; 559 break;
558 } 560 }
559
560 if (key[0] != '/') 561 if (key[0] != '/')
561 continue; 562 continue;
562 563
563 key = PDF_NameDecode(key); 564 key = PDF_NameDecode(key);
564 std::unique_ptr<CPDF_Object> obj( 565 std::unique_ptr<CPDF_Object> obj(
565 GetObject(pObjList, objnum, gennum, true)); 566 GetObject(pObjList, objnum, gennum, true));
566 if (!obj) { 567 if (!obj) {
567 uint8_t ch; 568 uint8_t ch;
568 while (GetNextChar(ch) && ch != 0x0A && ch != 0x0D) { 569 while (GetNextChar(ch) && ch != 0x0A && ch != 0x0D) {
569 continue; 570 continue;
570 } 571 }
571 return nullptr; 572 return nullptr;
572 } 573 }
573 574
574 if (key.GetLength() > 1) { 575 if (key.GetLength() > 1) {
575 pDict->SetFor(CFX_ByteString(key.c_str() + 1, key.GetLength() - 1), 576 pDict->SetFor(CFX_ByteString(key.c_str() + 1, key.GetLength() - 1),
576 obj.release()); 577 obj.release());
577 } 578 }
578 } 579 }
579 580
580 FX_FILESIZE SavedPos = m_Pos; 581 FX_FILESIZE SavedPos = m_Pos;
581 CFX_ByteString nextword = GetNextWord(nullptr); 582 CFX_ByteString nextword = GetNextWord(nullptr);
582 if (nextword != "stream") { 583 if (nextword != "stream") {
583 m_Pos = SavedPos; 584 m_Pos = SavedPos;
584 return pDict.release(); 585 return std::move(pDict);
585 } 586 }
586 587
587 return ReadStream(pDict.release(), objnum, gennum); 588 return ReadStream(pDict.release(), objnum, gennum);
588 } 589 }
589 590
590 if (word == ">>") 591 if (word == ">>")
591 m_Pos = SavedObjPos; 592 m_Pos = SavedObjPos;
592 593
593 return nullptr; 594 return nullptr;
594 } 595 }
595 596
596 unsigned int CPDF_SyntaxParser::ReadEOLMarkers(FX_FILESIZE pos) { 597 unsigned int CPDF_SyntaxParser::ReadEOLMarkers(FX_FILESIZE pos) {
597 unsigned char byte1 = 0; 598 unsigned char byte1 = 0;
598 unsigned char byte2 = 0; 599 unsigned char byte2 = 0;
599 600
600 GetCharAt(pos, byte1); 601 GetCharAt(pos, byte1);
601 GetCharAt(pos + 1, byte2); 602 GetCharAt(pos + 1, byte2);
602 603
603 if (byte1 == '\r' && byte2 == '\n') 604 if (byte1 == '\r' && byte2 == '\n')
604 return 2; 605 return 2;
605 606
606 if (byte1 == '\r' || byte1 == '\n') 607 if (byte1 == '\r' || byte1 == '\n')
607 return 1; 608 return 1;
608 609
609 return 0; 610 return 0;
610 } 611 }
611 612
612 CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, 613 std::unique_ptr<CPDF_Stream> CPDF_SyntaxParser::ReadStream(
613 uint32_t objnum, 614 CPDF_Dictionary* pDict,
614 uint32_t gennum) { 615 uint32_t objnum,
616 uint32_t gennum) {
615 CPDF_Object* pLenObj = pDict->GetObjectFor("Length"); 617 CPDF_Object* pLenObj = pDict->GetObjectFor("Length");
616 FX_FILESIZE len = -1; 618 FX_FILESIZE len = -1;
617 CPDF_Reference* pLenObjRef = ToReference(pLenObj); 619 CPDF_Reference* pLenObjRef = ToReference(pLenObj);
618 620
619 bool differingObjNum = !pLenObjRef || (pLenObjRef->GetObjList() && 621 bool differingObjNum = !pLenObjRef || (pLenObjRef->GetObjList() &&
620 pLenObjRef->GetRefObjNum() != objnum); 622 pLenObjRef->GetRefObjNum() != objnum);
621 if (pLenObj && differingObjNum) 623 if (pLenObj && differingObjNum)
622 len = pLenObj->GetInteger(); 624 len = pLenObj->GetInteger();
623 625
624 // Locate the start of stream. 626 // Locate the start of stream.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 pCryptoHandler->DecryptStream(context, pData, len, dest_buf); 742 pCryptoHandler->DecryptStream(context, pData, len, dest_buf);
741 pCryptoHandler->DecryptFinish(context, dest_buf); 743 pCryptoHandler->DecryptFinish(context, dest_buf);
742 744
743 FX_Free(pData); 745 FX_Free(pData);
744 pData = dest_buf.GetBuffer(); 746 pData = dest_buf.GetBuffer();
745 len = dest_buf.GetSize(); 747 len = dest_buf.GetSize();
746 dest_buf.DetachBuffer(); 748 dest_buf.DetachBuffer();
747 } 749 }
748 } 750 }
749 751
750 CPDF_Stream* pStream = new CPDF_Stream(pData, len, pDict); 752 auto pStream = pdfium::MakeUnique<CPDF_Stream>(pData, len, pDict);
751 streamStartPos = m_Pos; 753 streamStartPos = m_Pos;
752 FXSYS_memset(m_WordBuffer, 0, kEndObjStr.GetLength() + 1); 754 FXSYS_memset(m_WordBuffer, 0, kEndObjStr.GetLength() + 1);
753
754 GetNextWordInternal(nullptr); 755 GetNextWordInternal(nullptr);
755 756
756 int numMarkers = ReadEOLMarkers(m_Pos); 757 int numMarkers = ReadEOLMarkers(m_Pos);
757 if (m_WordSize == static_cast<unsigned int>(kEndObjStr.GetLength()) && 758 if (m_WordSize == static_cast<unsigned int>(kEndObjStr.GetLength()) &&
758 numMarkers != 0 && 759 numMarkers != 0 &&
759 FXSYS_memcmp(m_WordBuffer, kEndObjStr.raw_str(), 760 FXSYS_memcmp(m_WordBuffer, kEndObjStr.raw_str(),
760 kEndObjStr.GetLength()) == 0) { 761 kEndObjStr.GetLength()) == 0) {
761 m_Pos = streamStartPos; 762 m_Pos = streamStartPos;
762 } 763 }
763 return pStream; 764 return pStream;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 } 913 }
913 914
914 void CPDF_SyntaxParser::SetEncrypt( 915 void CPDF_SyntaxParser::SetEncrypt(
915 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) { 916 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) {
916 m_pCryptoHandler = std::move(pCryptoHandler); 917 m_pCryptoHandler = std::move(pCryptoHandler);
917 } 918 }
918 919
919 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) { 920 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) {
920 return m_pPool ? m_pPool->Intern(str) : str; 921 return m_pPool ? m_pPool->Intern(str) : str;
921 } 922 }
OLDNEW
« core/fpdfapi/parser/cpdf_parser.cpp ('K') | « core/fpdfapi/parser/cpdf_syntax_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698