summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_basic_bstring.cpp5
-rw-r--r--core/fxcrt/fx_basic_wstring.cpp5
2 files changed, 6 insertions, 4 deletions
diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp
index b4eb4a75e0..f049b14c3a 100644
--- a/core/fxcrt/fx_basic_bstring.cpp
+++ b/core/fxcrt/fx_basic_bstring.cpp
@@ -12,6 +12,7 @@
#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/fx_basic.h"
#include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/stl_util.h"
template class CFX_StringDataTemplate<char>;
template class CFX_StringCTemplate<char>;
@@ -405,8 +406,8 @@ CFX_ByteString CFX_ByteString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const {
if (!m_pData)
return CFX_ByteString();
- nFirst = std::min(std::max(nFirst, 0), m_pData->m_nDataLength);
- nCount = std::min(std::max(nCount, 0), m_pData->m_nDataLength - nFirst);
+ nFirst = pdfium::clamp(nFirst, 0, m_pData->m_nDataLength);
+ nCount = pdfium::clamp(nCount, 0, m_pData->m_nDataLength - nFirst);
if (nCount == 0)
return CFX_ByteString();
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp
index 8522d42a38..384b0b0086 100644
--- a/core/fxcrt/fx_basic_wstring.cpp
+++ b/core/fxcrt/fx_basic_wstring.cpp
@@ -13,6 +13,7 @@
#include "core/fxcrt/fx_basic.h"
#include "core/fxcrt/fx_ext.h"
#include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/stl_util.h"
template class CFX_StringDataTemplate<wchar_t>;
template class CFX_StringCTemplate<wchar_t>;
@@ -375,8 +376,8 @@ CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const {
if (!m_pData)
return CFX_WideString();
- nFirst = std::min(std::max(nFirst, 0), m_pData->m_nDataLength);
- nCount = std::min(std::max(nCount, 0), m_pData->m_nDataLength - nFirst);
+ nFirst = pdfium::clamp(nFirst, 0, m_pData->m_nDataLength);
+ nCount = pdfium::clamp(nCount, 0, m_pData->m_nDataLength - nFirst);
if (nCount == 0)
return CFX_WideString();