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

Side by Side Diff: core/fpdfapi/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: fix an undefined variable 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_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
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 uint32_t readSize =
602 m_pSyntax->m_pFileAccess->ReadBlock(buffer.data(), pos, size);
603 if (readSize != size && !m_pSyntax->m_pFileAccess->IsEOF())
602 break; 604 break;
603 605 size = readSize;
604 for (uint32_t i = 0; i < size; i++) { 606 for (uint32_t i = 0; i < size; i++) {
605 uint8_t byte = buffer[i]; 607 uint8_t byte = buffer[i];
606 switch (state) { 608 switch (state) {
607 case ParserState::kDefault: 609 case ParserState::kDefault:
608 if (PDFCharIsWhitespace(byte)) { 610 if (PDFCharIsWhitespace(byte)) {
609 state = ParserState::kWhitespace; 611 state = ParserState::kWhitespace;
610 } else if (std::isdigit(byte)) { 612 } else if (std::isdigit(byte)) {
611 --i; 613 --i;
612 state = ParserState::kWhitespace; 614 state = ParserState::kWhitespace;
613 } else if (byte == '%') { 615 } else if (byte == '%') {
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1574 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1573 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1575 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1574 m_LastXRefOffset = 0; 1576 m_LastXRefOffset = 0;
1575 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1577 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1576 return FORMAT_ERROR; 1578 return FORMAT_ERROR;
1577 } 1579 }
1578 1580
1579 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1581 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1580 return SUCCESS; 1582 return SUCCESS;
1581 } 1583 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698