| 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 "../include/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
| 8 #include "../include/fpdfview.h" | 8 #include "../include/fpdfview.h" |
| 9 #include "../include/fsdk_rendercontext.h" | 9 #include "../include/fsdk_rendercontext.h" |
| 10 #include "../include/fpdf_progressive.h" | 10 #include "../include/fpdf_progressive.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 292 |
| 293 class CMemFile FX_FINAL: public IFX_FileRead, public CFX_Object | 293 class CMemFile FX_FINAL: public IFX_FileRead, public CFX_Object |
| 294 { | 294 { |
| 295 public: | 295 public: |
| 296 CMemFile(FX_BYTE* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} | 296 CMemFile(FX_BYTE* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} |
| 297 | 297 |
| 298 virtual void Release() {delete this;} | 298 virtual void Release() {delete this;} |
| 299 virtual FX_FILESIZE GetSize() {return m_size;} | 299 virtual FX_FILESIZE GetSize() {return m_size;} |
| 300 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offs
et, size_t size) | 300 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offs
et, size_t size) |
| 301 { | 301 { |
| 302 if (offset < 0) { | 302 if (offset < 0) { |
| 303 return FALSE; | 303 return FALSE; |
| 304 } | 304 } |
| 305 FX_SAFE_FILESIZE newPos = base::checked_cast<FX_FILESIZE, size_t>(size); | 305 FX_SAFE_FILESIZE newPos = base::checked_cast<FX_FILESIZE, size_t>(si
ze); |
| 306 newPos += offset; | 306 newPos += offset; |
| 307 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) return
FALSE; | 307 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { |
| 308 » » FXSYS_memcpy(buffer, m_pBuf+offset, size); | 308 return FALSE; |
| 309 » » return TRUE; | 309 } |
| 310 » FXSYS_memcpy(buffer, m_pBuf+offset, size); |
| 311 » return TRUE; |
| 310 } | 312 } |
| 311 private: | 313 private: |
| 312 FX_BYTE* m_pBuf; | 314 FX_BYTE* m_pBuf; |
| 313 FX_FILESIZE m_size; | 315 FX_FILESIZE m_size; |
| 314 }; | 316 }; |
| 315 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int s
ize, FPDF_BYTESTRING password) | 317 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int s
ize, FPDF_BYTESTRING password) |
| 316 { | 318 { |
| 317 CPDF_Parser* pParser = FX_NEW CPDF_Parser; | 319 CPDF_Parser* pParser = FX_NEW CPDF_Parser; |
| 318 pParser->SetPassword(password); | 320 pParser->SetPassword(password); |
| 319 try { | 321 try { |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 { | 908 { |
| 907 if (document == NULL) | 909 if (document == NULL) |
| 908 return NULL; | 910 return NULL; |
| 909 if (name == NULL || name[0] == 0) | 911 if (name == NULL || name[0] == 0) |
| 910 return NULL; | 912 return NULL; |
| 911 | 913 |
| 912 CPDF_Document* pDoc = (CPDF_Document*)document; | 914 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 913 CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); | 915 CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); |
| 914 return name_tree.LookupNamedDest(pDoc, name); | 916 return name_tree.LookupNamedDest(pDoc, name); |
| 915 } | 917 } |
| OLD | NEW |