| 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/fpdf_parser/cpdf_syntax_parser.h" | 7 #include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 if ((FX_FILESIZE)(read_pos + read_size) > m_FileLen) { | 71 if ((FX_FILESIZE)(read_pos + read_size) > m_FileLen) { |
| 72 if (m_FileLen < (FX_FILESIZE)read_size) { | 72 if (m_FileLen < (FX_FILESIZE)read_size) { |
| 73 read_pos = 0; | 73 read_pos = 0; |
| 74 read_size = (uint32_t)m_FileLen; | 74 read_size = (uint32_t)m_FileLen; |
| 75 } else { | 75 } else { |
| 76 read_pos = m_FileLen - read_size; | 76 read_pos = m_FileLen - read_size; |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) | 80 if (m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size) != |
| 81 read_size && |
| 82 !m_pFileAccess->IsEOF()) |
| 81 return FALSE; | 83 return FALSE; |
| 82 | 84 |
| 83 m_BufOffset = read_pos; | 85 m_BufOffset = read_pos; |
| 84 } | 86 } |
| 85 ch = m_pFileBuf[pos - m_BufOffset]; | 87 ch = m_pFileBuf[pos - m_BufOffset]; |
| 86 m_Pos++; | 88 m_Pos++; |
| 87 return TRUE; | 89 return TRUE; |
| 88 } | 90 } |
| 89 | 91 |
| 90 FX_BOOL CPDF_SyntaxParser::GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch) { | 92 FX_BOOL CPDF_SyntaxParser::GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 102 uint32_t read_size = m_BufSize; | 104 uint32_t read_size = m_BufSize; |
| 103 if ((FX_FILESIZE)(read_pos + read_size) > m_FileLen) { | 105 if ((FX_FILESIZE)(read_pos + read_size) > m_FileLen) { |
| 104 if (m_FileLen < (FX_FILESIZE)read_size) { | 106 if (m_FileLen < (FX_FILESIZE)read_size) { |
| 105 read_pos = 0; | 107 read_pos = 0; |
| 106 read_size = (uint32_t)m_FileLen; | 108 read_size = (uint32_t)m_FileLen; |
| 107 } else { | 109 } else { |
| 108 read_pos = m_FileLen - read_size; | 110 read_pos = m_FileLen - read_size; |
| 109 } | 111 } |
| 110 } | 112 } |
| 111 | 113 |
| 112 if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) | 114 if (m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size) != |
| 115 read_size && |
| 116 !m_pFileAccess->IsEOF()) |
| 113 return FALSE; | 117 return FALSE; |
| 114 | 118 |
| 115 m_BufOffset = read_pos; | 119 m_BufOffset = read_pos; |
| 116 } | 120 } |
| 117 ch = m_pFileBuf[pos - m_BufOffset]; | 121 ch = m_pFileBuf[pos - m_BufOffset]; |
| 118 return TRUE; | 122 return TRUE; |
| 119 } | 123 } |
| 120 | 124 |
| 121 FX_BOOL CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, uint32_t size) { | 125 FX_BOOL CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, uint32_t size) { |
| 122 if (!m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size)) | 126 if (m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size) != size && |
| 127 !m_pFileAccess->IsEOF()) |
| 123 return FALSE; | 128 return FALSE; |
| 124 m_Pos += size; | 129 m_Pos += size; |
| 125 return TRUE; | 130 return TRUE; |
| 126 } | 131 } |
| 127 | 132 |
| 128 void CPDF_SyntaxParser::GetNextWordInternal(bool* bIsNumber) { | 133 void CPDF_SyntaxParser::GetNextWordInternal(bool* bIsNumber) { |
| 129 m_WordSize = 0; | 134 m_WordSize = 0; |
| 130 if (bIsNumber) | 135 if (bIsNumber) |
| 131 *bIsNumber = true; | 136 *bIsNumber = true; |
| 132 | 137 |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 } | 993 } |
| 989 | 994 |
| 990 void CPDF_SyntaxParser::SetEncrypt( | 995 void CPDF_SyntaxParser::SetEncrypt( |
| 991 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) { | 996 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) { |
| 992 m_pCryptoHandler = std::move(pCryptoHandler); | 997 m_pCryptoHandler = std::move(pCryptoHandler); |
| 993 } | 998 } |
| 994 | 999 |
| 995 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) { | 1000 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) { |
| 996 return m_pPool ? m_pPool->Intern(str) : str; | 1001 return m_pPool ? m_pPool->Intern(str) : str; |
| 997 } | 1002 } |
| OLD | NEW |