From 0f9b0a9d72a46cf708866aebc5f1103087b3d2c2 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 17 Apr 2017 11:30:25 -0700 Subject: Require unique_ptr arg for CXFA_FMLexer::SetToken() Change-Id: Id252b3b2208ac9f792220605ddc1eb3ba29e2d55 Reviewed-on: https://pdfium-review.googlesource.com/4260 Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fxfa/fm2js/xfa_fmparse.cpp | 5 +++-- xfa/fxfa/fm2js/xfa_lexer.h | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/xfa/fxfa/fm2js/xfa_fmparse.cpp b/xfa/fxfa/fm2js/xfa_fmparse.cpp index c1f609315b..298a2eb334 100644 --- a/xfa/fxfa/fm2js/xfa_fmparse.cpp +++ b/xfa/fxfa/fm2js/xfa_fmparse.cpp @@ -857,10 +857,11 @@ std::unique_ptr CXFA_FMParse::ParseIfExpression() { Check(TOKrparen); if (m_pToken->m_type != TOKthen) { m_lexer->SetCurrentLine(line); - m_pToken = new CXFA_FMToken(line); + auto pNewToken = pdfium::MakeUnique(line); + m_pToken = pNewToken.get(); m_pToken->m_type = TOKidentifier; m_pToken->m_wstring = L"if"; - m_lexer->SetToken(m_pToken); + m_lexer->SetToken(std::move(pNewToken)); m_lexer->RestorePos(pStartPos); return ParseExpExpression(); } diff --git a/xfa/fxfa/fm2js/xfa_lexer.h b/xfa/fxfa/fm2js/xfa_lexer.h index 860c50f30a..100f757dc0 100644 --- a/xfa/fxfa/fm2js/xfa_lexer.h +++ b/xfa/fxfa/fm2js/xfa_lexer.h @@ -8,6 +8,7 @@ #define XFA_FXFA_FM2JS_XFA_LEXER_H_ #include +#include #include "core/fxcrt/fx_string.h" #include "xfa/fxfa/fm2js/xfa_error.h" @@ -113,9 +114,8 @@ class CXFA_FMLexer { void Comment(const wchar_t* p, const wchar_t*& pEnd); XFA_FM_TOKEN IsKeyword(const CFX_WideStringC& p); void SetCurrentLine(uint32_t line) { m_uCurrentLine = line; } - void SetToken(CXFA_FMToken* pToken) { - if (m_pToken.get() != pToken) - m_pToken.reset(pToken); + void SetToken(std::unique_ptr pToken) { + m_pToken = std::move(pToken); } const wchar_t* SavePos() { return m_ptr; } void RestorePos(const wchar_t* pPos) { m_ptr = pPos; } -- cgit v1.2.3