From 6f62ccd50ff85ba6a60ddf47993745739854cd8f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 10 May 2017 13:38:20 -0700 Subject: Check CXFA_FM2JSContext::Translate() return value. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove not useful error parameter. Change-Id: I6f49a51a47c9d7f45e75a585679e15f0414aac26 Reviewed-on: https://pdfium-review.googlesource.com/5254 Commit-Queue: Lei Zhang Reviewed-by: Nicolás Peña --- xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 30 ++++++++++++++---------------- xfa/fxfa/fm2js/xfa_fm2jscontext.h | 3 +-- xfa/fxfa/fm2js/xfa_program.h | 2 -- xfa/fxfa/parser/cxfa_scriptcontext.cpp | 5 +---- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index 172c234aca..8879b94373 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -2778,10 +2778,13 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, } CFX_WideTextBuf wsJavaScriptBuf; - CFX_WideString wsError; - CXFA_FM2JSContext::Translate( - CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), - wsJavaScriptBuf, wsError); + if (CXFA_FM2JSContext::Translate( + CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), + &wsJavaScriptBuf)) { + pContext->ThrowCompilerErrorException(); + return; + } + std::unique_ptr pNewContext( CFXJSE_Context::Create(pIsolate, nullptr, nullptr)); @@ -5430,10 +5433,8 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, CFX_WideString scriptString = CFX_WideString::FromUTF8(argString.AsStringC()); CFX_WideTextBuf wsJavaScriptBuf; - CFX_WideString wsError; - CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf, - wsError); - if (!wsError.IsEmpty()) { + if (CXFA_FM2JSContext::Translate(scriptString.AsStringC(), + &wsJavaScriptBuf)) { pContext->ThrowCompilerErrorException(); return; } @@ -6112,20 +6113,17 @@ CFX_ByteString CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg) { // static. int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc, - CFX_WideTextBuf& wsJavascript, - CFX_WideString& wsError) { + CFX_WideTextBuf* wsJavascript) { if (wsFormcalc.IsEmpty()) { - wsJavascript.Clear(); - wsError.clear(); + wsJavascript->Clear(); return 0; } CXFA_FMProgram program(wsFormcalc); int32_t status = program.ParseProgram(); - if (status) { - wsError = program.GetError().message; + if (status) return status; - } - program.TranslateProgram(wsJavascript); + + program.TranslateProgram(*wsJavascript); return 0; } diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/fxfa/fm2js/xfa_fm2jscontext.h index 33f739f1cc..bde185d28c 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.h +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.h @@ -428,8 +428,7 @@ class CXFA_FM2JSContext : public CFXJSE_HostObject { bool* ret); static int32_t Translate(const CFX_WideStringC& wsFormcalc, - CFX_WideTextBuf& wsJavascript, - CFX_WideString& wsError); + CFX_WideTextBuf* wsJavascript); void GlobalPropertyGetter(CFXJSE_Value* pValue); diff --git a/xfa/fxfa/fm2js/xfa_program.h b/xfa/fxfa/fm2js/xfa_program.h index 7a2dade6fd..a00a5037da 100644 --- a/xfa/fxfa/fm2js/xfa_program.h +++ b/xfa/fxfa/fm2js/xfa_program.h @@ -20,8 +20,6 @@ class CXFA_FMProgram { int32_t ParseProgram(); int32_t TranslateProgram(CFX_WideTextBuf& wsJavaScript); - const CXFA_FMErrorInfo& GetError() const { return m_pErrorInfo; } - private: CXFA_FMErrorInfo m_pErrorInfo; CXFA_FMParse m_parse; diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp index e7697f5fab..a3aed388be 100644 --- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp +++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp @@ -153,10 +153,7 @@ bool CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType, m_pIsolate, m_JsContext.get(), m_pDocument); } CFX_WideTextBuf wsJavaScript; - CFX_WideString wsErrorInfo; - int32_t iFlags = - CXFA_FM2JSContext::Translate(wsScript, wsJavaScript, wsErrorInfo); - if (iFlags) { + if (CXFA_FM2JSContext::Translate(wsScript, &wsJavaScript)) { hRetValue->SetUndefined(); return false; } -- cgit v1.2.3