OLD | NEW |
---|---|
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_parser.h" | 7 #include "core/fpdfapi/parser/cpdf_parser.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 FX_FILESIZE start_pos1 = 0; | 591 FX_FILESIZE start_pos1 = 0; |
592 FX_FILESIZE last_obj = -1; | 592 FX_FILESIZE last_obj = -1; |
593 FX_FILESIZE last_xref = -1; | 593 FX_FILESIZE last_xref = -1; |
594 FX_FILESIZE last_trailer = -1; | 594 FX_FILESIZE last_trailer = -1; |
595 | 595 |
596 while (pos < m_pSyntax->m_FileLen) { | 596 while (pos < m_pSyntax->m_FileLen) { |
597 const FX_FILESIZE saved_pos = pos; | 597 const FX_FILESIZE saved_pos = pos; |
598 bool bOverFlow = false; | 598 bool bOverFlow = false; |
599 uint32_t size = | 599 uint32_t size = |
600 std::min((uint32_t)(m_pSyntax->m_FileLen - pos), kBufferSize); | 600 std::min((uint32_t)(m_pSyntax->m_FileLen - pos), kBufferSize); |
601 if (!m_pSyntax->m_pFileAccess->ReadBlock(buffer.data(), pos, size)) | 601 if (m_pSyntax->m_pFileAccess->ReadBlock(buffer.data(), pos, size) != size && |
602 !m_pSyntax->m_pFileAccess->IsEOF()) | |
602 break; | 603 break; |
603 | 604 |
604 for (uint32_t i = 0; i < size; i++) { | 605 for (uint32_t i = 0; i < size; i++) { |
605 uint8_t byte = buffer[i]; | 606 uint8_t byte = buffer[i]; |
Tom Sepez
2016/11/14 20:27:40
and here.
| |
606 switch (state) { | 607 switch (state) { |
607 case ParserState::kDefault: | 608 case ParserState::kDefault: |
608 if (PDFCharIsWhitespace(byte)) { | 609 if (PDFCharIsWhitespace(byte)) { |
609 state = ParserState::kWhitespace; | 610 state = ParserState::kWhitespace; |
610 } else if (std::isdigit(byte)) { | 611 } else if (std::isdigit(byte)) { |
611 --i; | 612 --i; |
612 state = ParserState::kWhitespace; | 613 state = ParserState::kWhitespace; |
613 } else if (byte == '%') { | 614 } else if (byte == '%') { |
614 inside_index = 0; | 615 inside_index = 0; |
615 state = ParserState::kComment; | 616 state = ParserState::kComment; |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1572 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && | 1573 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && |
1573 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1574 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
1574 m_LastXRefOffset = 0; | 1575 m_LastXRefOffset = 0; |
1575 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1576 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1576 return FORMAT_ERROR; | 1577 return FORMAT_ERROR; |
1577 } | 1578 } |
1578 | 1579 |
1579 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1580 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1580 return SUCCESS; | 1581 return SUCCESS; |
1581 } | 1582 } |
OLD | NEW |