| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "public/fpdfview.h" | 7 #include "public/fpdfview.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 384 |
| 385 void Release() override { delete this; } | 385 void Release() override { delete this; } |
| 386 FX_FILESIZE GetSize() override { return m_size; } | 386 FX_FILESIZE GetSize() override { return m_size; } |
| 387 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { | 387 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { |
| 388 if (offset < 0) { | 388 if (offset < 0) { |
| 389 return FALSE; | 389 return FALSE; |
| 390 } | 390 } |
| 391 FX_SAFE_FILESIZE newPos = | 391 FX_SAFE_FILESIZE newPos = |
| 392 pdfium::base::checked_cast<FX_FILESIZE, size_t>(size); | 392 pdfium::base::checked_cast<FX_FILESIZE, size_t>(size); |
| 393 newPos += offset; | 393 newPos += offset; |
| 394 if (!newPos.IsValid() || newPos.ValueOrDie() > (uint32_t)m_size) { | 394 if (!newPos.IsValid() || newPos.ValueOrDie() > m_size) { |
| 395 return FALSE; | 395 return FALSE; |
| 396 } | 396 } |
| 397 FXSYS_memcpy(buffer, m_pBuf + offset, size); | 397 FXSYS_memcpy(buffer, m_pBuf + offset, size); |
| 398 return TRUE; | 398 return TRUE; |
| 399 } | 399 } |
| 400 | 400 |
| 401 private: | 401 private: |
| 402 ~CMemFile() override {} | 402 ~CMemFile() override {} |
| 403 | 403 |
| 404 uint8_t* const m_pBuf; | 404 uint8_t* const m_pBuf; |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) { | 1148 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) { |
| 1149 pDestObj = pDict->GetArrayBy("D"); | 1149 pDestObj = pDict->GetArrayBy("D"); |
| 1150 if (!pDestObj) | 1150 if (!pDestObj) |
| 1151 return nullptr; | 1151 return nullptr; |
| 1152 } | 1152 } |
| 1153 if (!pDestObj->IsArray()) | 1153 if (!pDestObj->IsArray()) |
| 1154 return nullptr; | 1154 return nullptr; |
| 1155 | 1155 |
| 1156 CFX_WideString wsName = PDF_DecodeText(bsName); | 1156 CFX_WideString wsName = PDF_DecodeText(bsName); |
| 1157 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); | 1157 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); |
| 1158 unsigned int len = utf16Name.GetLength(); | 1158 int len = utf16Name.GetLength(); |
| 1159 if (!buffer) { | 1159 if (!buffer) { |
| 1160 *buflen = len; | 1160 *buflen = len; |
| 1161 } else if (*buflen >= len) { | 1161 } else if (*buflen >= len) { |
| 1162 memcpy(buffer, utf16Name.c_str(), len); | 1162 memcpy(buffer, utf16Name.c_str(), len); |
| 1163 *buflen = len; | 1163 *buflen = len; |
| 1164 } else { | 1164 } else { |
| 1165 *buflen = -1; | 1165 *buflen = -1; |
| 1166 } | 1166 } |
| 1167 return (FPDF_DEST)pDestObj; | 1167 return (FPDF_DEST)pDestObj; |
| 1168 } | 1168 } |
| OLD | NEW |