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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_parser.cpp

Issue 2430743003: in the attempt to fix 627393, changed IFX_FileRead's readBlock to return the length it reads
Patch Set: remove .tmp files Created 4 years, 2 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
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/fpdf_parser/include/cpdf_parser.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 FX_FILESIZE start_pos1 = 0; 611 FX_FILESIZE start_pos1 = 0;
612 FX_FILESIZE last_obj = -1; 612 FX_FILESIZE last_obj = -1;
613 FX_FILESIZE last_xref = -1; 613 FX_FILESIZE last_xref = -1;
614 FX_FILESIZE last_trailer = -1; 614 FX_FILESIZE last_trailer = -1;
615 615
616 while (pos < m_pSyntax->m_FileLen) { 616 while (pos < m_pSyntax->m_FileLen) {
617 const FX_FILESIZE saved_pos = pos; 617 const FX_FILESIZE saved_pos = pos;
618 bool bOverFlow = false; 618 bool bOverFlow = false;
619 uint32_t size = 619 uint32_t size =
620 std::min((uint32_t)(m_pSyntax->m_FileLen - pos), kBufferSize); 620 std::min((uint32_t)(m_pSyntax->m_FileLen - pos), kBufferSize);
621 if (!m_pSyntax->m_pFileAccess->ReadBlock(buffer.data(), pos, size)) 621 if (m_pSyntax->m_pFileAccess->ReadBlock(buffer.data(), pos, size) != size &&
622 !m_pSyntax->m_pFileAccess->IsEOF())
622 break; 623 break;
623 624
624 for (uint32_t i = 0; i < size; i++) { 625 for (uint32_t i = 0; i < size; i++) {
625 uint8_t byte = buffer[i]; 626 uint8_t byte = buffer[i];
626 switch (state) { 627 switch (state) {
627 case ParserState::kDefault: 628 case ParserState::kDefault:
628 if (PDFCharIsWhitespace(byte)) { 629 if (PDFCharIsWhitespace(byte)) {
629 state = ParserState::kWhitespace; 630 state = ParserState::kWhitespace;
630 } else if (std::isdigit(byte)) { 631 } else if (std::isdigit(byte)) {
631 --i; 632 --i;
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1629 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1629 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1630 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1630 m_LastXRefOffset = 0; 1631 m_LastXRefOffset = 0;
1631 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1632 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1632 return FORMAT_ERROR; 1633 return FORMAT_ERROR;
1633 } 1634 }
1634 1635
1635 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1636 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1636 return SUCCESS; 1637 return SUCCESS;
1637 } 1638 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698