From 33b42e4ab56d56ff02cd08a47c5f590875d886bf Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 19 Jul 2017 13:19:12 -0700 Subject: Rename StringCs c_str() to unterminated_c_str(). Since there is no guarantee of termination if the StringC was extracted from a snippet of another string. Make it more obvious that things like strlen(str.unterminated_c_str()) might be a bad idea. Change-Id: I7832248ed89ebbddf5c0bcd402aac7d40ec2adc2 Reviewed-on: https://pdfium-review.googlesource.com/8170 Commit-Queue: Tom Sepez Reviewed-by: dsinclair Reviewed-by: Henrique Nakashima --- xfa/fde/css/cfde_cssdeclaration.cpp | 3 +-- xfa/fde/css/cfde_cssselector.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'xfa/fde/css') diff --git a/xfa/fde/css/cfde_cssdeclaration.cpp b/xfa/fde/css/cfde_cssdeclaration.cpp index 00a2c9e33c..e15e5f7fe7 100644 --- a/xfa/fde/css/cfde_cssdeclaration.cpp +++ b/xfa/fde/css/cfde_cssdeclaration.cpp @@ -160,9 +160,8 @@ void CFDE_CSSDeclaration::AddProperty(const FDE_CSSPropertyTable* pTable, const CFX_WideStringC& value) { ASSERT(!value.IsEmpty()); - const wchar_t* pszValue = value.c_str(); + const wchar_t* pszValue = value.unterminated_c_str(); int32_t iValueLen = value.GetLength(); - bool bImportant = false; if (iValueLen >= 10 && pszValue[iValueLen - 10] == '!' && FXSYS_wcsnicmp(L"important", pszValue + iValueLen - 9, 9) == 0) { diff --git a/xfa/fde/css/cfde_cssselector.cpp b/xfa/fde/css/cfde_cssselector.cpp index c1e9f7f22a..ad2ec40c2b 100644 --- a/xfa/fde/css/cfde_cssselector.cpp +++ b/xfa/fde/css/cfde_cssselector.cpp @@ -52,7 +52,7 @@ std::unique_ptr CFDE_CSSSelector::FromString( const CFX_WideStringC& str) { ASSERT(!str.IsEmpty()); - const wchar_t* psz = str.c_str(); + const wchar_t* psz = str.unterminated_c_str(); const wchar_t* pStart = psz; const wchar_t* pEnd = psz + str.GetLength(); for (; psz < pEnd; ++psz) { -- cgit v1.2.3