From 334319477703b5ba136373c4e3598e9a56e7f081 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 21 Apr 2016 11:17:22 -0700 Subject: Assert that CFX_ strings are pointer-size. The principle has been implicit in the implementation, but make it obvious for future generations. Review URL: https://codereview.chromium.org/1904143002 --- core/fxcrt/fx_basic_bstring.cpp | 3 +++ core/fxcrt/fx_basic_wstring.cpp | 3 +++ 2 files changed, 6 insertions(+) (limited to 'core/fxcrt') diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index bfa0cbd98c..1622c4bc55 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -75,6 +75,9 @@ const FX_CHAR* FX_strstr(const FX_CHAR* haystack, } // namespace +static_assert(sizeof(CFX_ByteString) <= sizeof(FX_CHAR*), + "Strings must not require more space than pointers"); + CFX_ByteString::CFX_ByteString(const FX_CHAR* pStr, FX_STRSIZE nLen) { if (nLen < 0) nLen = pStr ? FXSYS_strlen(pStr) : 0; diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp index 069b9fa42d..f3b430c7bf 100644 --- a/core/fxcrt/fx_basic_wstring.cpp +++ b/core/fxcrt/fx_basic_wstring.cpp @@ -59,6 +59,9 @@ const FX_WCHAR* FX_wcsstr(const FX_WCHAR* haystack, } // namespace +static_assert(sizeof(CFX_WideString) <= sizeof(FX_WCHAR*), + "Strings must not require more space than pointers"); + CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) { if (nLen < 0) nLen = pStr ? FXSYS_wcslen(pStr) : 0; -- cgit v1.2.3