From 052a8d963af8bb186b956057763021624332c7a8 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 19 Feb 2016 14:41:46 -0800 Subject: Revert "Revert "Use safe arithmentic in CFX_BinaryBuf::ExpandBuf."" This relands the CL at https://codereview.chromium.org/1710403002 Tests passed locally. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1717603003 . --- xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp | 25 +++++++++++++++++-------- xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp | 4 ++-- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'xfa/src/fxfa') diff --git a/xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp b/xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp index 529474f5eb..77cf79bd7b 100644 --- a/xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp @@ -3760,8 +3760,9 @@ void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, ++i; } wsResultBuf.AppendChar(0); - szResultString = - FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()); + szResultString.Clear(); + szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); } void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, CFX_ByteTextBuf& szResultString) { @@ -3833,8 +3834,9 @@ void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, ++i; } wsResultBuf.AppendChar(0); - szResultString = - FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()); + szResultString.Clear(); + szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); } void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, CFX_ByteTextBuf& szResultString) { @@ -3930,7 +3932,8 @@ void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, iCode = 0; } wsXMLBuf.AppendChar(0); - szResultString = FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()); + szResultString.Clear(); + szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()); } void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis, const CFX_ByteStringC& szFuncName, @@ -4083,7 +4086,9 @@ void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, } } wsResultBuf.AppendChar(0); - szResultBuf = FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()); + szResultBuf.Clear(); + szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); } void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, CFX_ByteTextBuf& szResultBuf) { @@ -4135,7 +4140,9 @@ void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, ++i; } wsResultBuf.AppendChar(0); - szResultBuf = FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()); + szResultBuf.Clear(); + szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); } void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, CFX_ByteTextBuf& szResultBuf) { @@ -4215,7 +4222,9 @@ void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, } } wsResultBuf.AppendChar(0); - szResultBuf = FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()); + szResultBuf.Clear(); + szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); } FX_BOOL CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData, uint32_t& iCode) { diff --git a/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp b/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp index c67681f6ba..7048c38d5a 100644 --- a/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp +++ b/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp @@ -447,8 +447,8 @@ CXFA_FMCallExpression::~CXFA_FMCallExpression() { } } FX_BOOL CXFA_FMCallExpression::IsBuildInFunc(CFX_WideTextBuf& funcName) { - int32_t iLength = funcName.GetLength(); - uint32_t uHash = FX_HashCode_String_GetW(funcName.GetBuffer(), iLength, TRUE); + uint32_t uHash = + FX_HashCode_String_GetW(funcName.GetBuffer(), funcName.GetLength(), TRUE); XFA_FMBuildInFunc buildinfunction; int32_t iStart = 0, iEnd = (sizeof(buildInFuncs) / sizeof(buildInFuncs[0])) - 1; -- cgit v1.2.3