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 "../../core/include/fpdfapi/fpdf_module.h" | 7 #include "../../core/include/fpdfapi/fpdf_module.h" |
8 #include "../../core/include/fxcodec/fx_codec.h" | 8 #include "../../core/include/fxcodec/fx_codec.h" |
9 #include "../../core/include/fxcrt/fx_safe_types.h" | 9 #include "../../core/include/fxcrt/fx_safe_types.h" |
10 #include "../../public/fpdf_ext.h" | 10 #include "../../public/fpdf_ext.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 pdfium::base::checked_cast<FX_FILESIZE, size_t>(size); | 316 pdfium::base::checked_cast<FX_FILESIZE, size_t>(size); |
317 newPos += offset; | 317 newPos += offset; |
318 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { | 318 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { |
319 return FALSE; | 319 return FALSE; |
320 } | 320 } |
321 FXSYS_memcpy(buffer, m_pBuf + offset, size); | 321 FXSYS_memcpy(buffer, m_pBuf + offset, size); |
322 return TRUE; | 322 return TRUE; |
323 } | 323 } |
324 | 324 |
325 private: | 325 private: |
| 326 ~CMemFile() override {} |
| 327 |
326 uint8_t* m_pBuf; | 328 uint8_t* m_pBuf; |
327 FX_FILESIZE m_size; | 329 FX_FILESIZE m_size; |
328 }; | 330 }; |
329 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, | 331 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, |
330 int size, | 332 int size, |
331 FPDF_BYTESTRING password) { | 333 FPDF_BYTESTRING password) { |
332 CPDF_Parser* pParser = new CPDF_Parser; | 334 CPDF_Parser* pParser = new CPDF_Parser; |
333 pParser->SetPassword(password); | 335 pParser->SetPassword(password); |
334 CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); | 336 CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); |
335 FX_DWORD err_code = pParser->StartParse(pMemFile); | 337 FX_DWORD err_code = pParser->StartParse(pMemFile); |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 if (!buffer) { | 1094 if (!buffer) { |
1093 *buflen = len; | 1095 *buflen = len; |
1094 } else if (*buflen >= len) { | 1096 } else if (*buflen >= len) { |
1095 memcpy(buffer, utf16Name.c_str(), len); | 1097 memcpy(buffer, utf16Name.c_str(), len); |
1096 *buflen = len; | 1098 *buflen = len; |
1097 } else { | 1099 } else { |
1098 *buflen = -1; | 1100 *buflen = -1; |
1099 } | 1101 } |
1100 return (FPDF_DEST)pDestObj; | 1102 return (FPDF_DEST)pDestObj; |
1101 } | 1103 } |
OLD | NEW |