| 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/fxcrt/extension.h" | 7 #include "core/fxcrt/extension.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 return m_nCurPos >= (size_t)GetSize(); | 197 return m_nCurPos >= (size_t)GetSize(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 FX_FILESIZE CFX_MemoryStream::GetPosition() { | 200 FX_FILESIZE CFX_MemoryStream::GetPosition() { |
| 201 return (FX_FILESIZE)m_nCurPos; | 201 return (FX_FILESIZE)m_nCurPos; |
| 202 } | 202 } |
| 203 | 203 |
| 204 bool CFX_MemoryStream::ReadBlock(void* buffer, | 204 bool CFX_MemoryStream::ReadBlock(void* buffer, |
| 205 FX_FILESIZE offset, | 205 FX_FILESIZE offset, |
| 206 size_t size) { | 206 size_t size) { |
| 207 if (!buffer || !size) | 207 if (!buffer || !size || offset < 0) |
| 208 return false; | 208 return false; |
| 209 | 209 |
| 210 FX_SAFE_SIZE_T newPos = size; | 210 FX_SAFE_SIZE_T newPos = size; |
| 211 newPos += offset; | 211 newPos += offset; |
| 212 if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 || | 212 if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 || |
| 213 newPos.ValueOrDie() > m_nCurSize) { | 213 newPos.ValueOrDie() > m_nCurSize) { |
| 214 return false; | 214 return false; |
| 215 } | 215 } |
| 216 | 216 |
| 217 m_nCurPos = newPos.ValueOrDie(); | 217 m_nCurPos = newPos.ValueOrDie(); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 b = ((const uint8_t*)pGUID)[i]; | 667 b = ((const uint8_t*)pGUID)[i]; |
| 668 *pBuf++ = gs_FX_pHexChars[b >> 4]; | 668 *pBuf++ = gs_FX_pHexChars[b >> 4]; |
| 669 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; | 669 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; |
| 670 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { | 670 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
| 671 *pBuf++ = L'-'; | 671 *pBuf++ = L'-'; |
| 672 } | 672 } |
| 673 } | 673 } |
| 674 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); | 674 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
| 675 } | 675 } |
| 676 #endif // PDF_ENABLE_XFA | 676 #endif // PDF_ENABLE_XFA |
| OLD | NEW |