summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-04-28 17:29:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-28 17:29:19 -0700
commit495bda110a6ea8e7a6fc313ec0232a9ca6e3cfdc (patch)
tree42abda300274f81009bdb9866e0f7e3f81164726 /xfa/fxfa
parenta31098417852bdf13e693a6e0913e0706cf94098 (diff)
downloadpdfium-495bda110a6ea8e7a6fc313ec0232a9ca6e3cfdc.tar.xz
Do not check pointers before deleting them.
XFA edition. Review-Url: https://codereview.chromium.org/1925363002
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/app/xfa_ffdocview.cpp7
-rw-r--r--xfa/fxfa/app/xfa_ffpushbutton.cpp26
-rw-r--r--xfa/fxfa/app/xfa_ffwidget.cpp13
-rw-r--r--xfa/fxfa/app/xfa_textlayout.cpp18
-rw-r--r--xfa/fxfa/parser/xfa_document_imp.cpp55
-rw-r--r--xfa/fxfa/parser/xfa_document_layout_imp.cpp25
-rw-r--r--xfa/fxfa/parser/xfa_locale.cpp11
-rw-r--r--xfa/fxfa/parser/xfa_parser_imp.cpp8
-rw-r--r--xfa/fxfa/parser/xfa_script_imp.cpp156
-rw-r--r--xfa/fxfa/parser/xfa_script_resolveprocessor.cpp11
10 files changed, 147 insertions, 183 deletions
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp
index d58b594e27..cd48a43a0e 100644
--- a/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/xfa/fxfa/app/xfa_ffdocview.cpp
@@ -62,13 +62,12 @@ CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc)
m_pOldFocusWidget(nullptr),
m_iStatus(XFA_DOCVIEW_LAYOUTSTATUS_None),
m_iLock(0) {}
+
CXFA_FFDocView::~CXFA_FFDocView() {
DestroyDocView();
- if (m_pWidgetHandler) {
- delete m_pWidgetHandler;
- }
- m_pWidgetHandler = NULL;
+ delete m_pWidgetHandler;
}
+
void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) {
RunBindItems();
ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize);
diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp
index 3893bc29fb..6db2b7078c 100644
--- a/xfa/fxfa/app/xfa_ffpushbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp
@@ -86,25 +86,19 @@ void CXFA_FFPushButton::UpdateWidgetProperty() {
}
m_pNormalWidget->ModifyStylesEx(dwStyleEx, 0xFFFFFFFF);
}
+
void CXFA_FFPushButton::UnloadWidget() {
- if (m_pRolloverTextLayout) {
- delete m_pRolloverTextLayout;
- m_pRolloverTextLayout = NULL;
- }
- if (m_pDownTextLayout) {
- delete m_pDownTextLayout;
- m_pDownTextLayout = NULL;
- }
- if (m_pDownProvider) {
- delete m_pDownProvider;
- m_pDownProvider = NULL;
- }
- if (m_pRollProvider) {
- delete m_pRollProvider;
- m_pRollProvider = NULL;
- }
+ delete m_pRolloverTextLayout;
+ m_pRolloverTextLayout = nullptr;
+ delete m_pDownTextLayout;
+ m_pDownTextLayout = nullptr;
+ delete m_pDownProvider;
+ m_pDownProvider = nullptr;
+ delete m_pRollProvider;
+ m_pRollProvider = nullptr;
CXFA_FFField::UnloadWidget();
}
+
FX_BOOL CXFA_FFPushButton::PerformLayout() {
CXFA_FFWidget::PerformLayout();
CFX_RectF rtWidget;
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp
index 34b29c79d2..c1af34c030 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -526,17 +526,14 @@ CXFA_ImageRenderer::CXFA_ImageRenderer() {
m_Result = TRUE;
m_bPrint = FALSE;
}
+
CXFA_ImageRenderer::~CXFA_ImageRenderer() {
- if (m_pCloneConvert) {
- delete m_pCloneConvert;
- }
- if (m_pTransformer) {
- delete m_pTransformer;
- }
- if (m_DeviceHandle) {
+ delete m_pCloneConvert;
+ delete m_pTransformer;
+ if (m_DeviceHandle)
m_pDevice->CancelDIBits(m_DeviceHandle);
- }
}
+
FX_BOOL CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice,
CFX_DIBSource* pDIBSource,
FX_ARGB bitmap_argb,
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp
index f2479b7d2f..9ed84e1604 100644
--- a/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/xfa/fxfa/app/xfa_textlayout.cpp
@@ -996,6 +996,7 @@ int32_t CXFA_TextLayout::CountBlocks() const {
int32_t iCount = m_Blocks.GetSize() / 2;
return iCount > 0 ? iCount : 1;
}
+
FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize,
const CFX_SizeF& maxSize,
CFX_SizeF& defaultSize) {
@@ -1014,13 +1015,12 @@ FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize,
if (fLinePos < 0.1f) {
fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL);
}
- if (m_pTabstopContext) {
- delete m_pTabstopContext;
- m_pTabstopContext = NULL;
- }
+ delete m_pTabstopContext;
+ m_pTabstopContext = nullptr;
defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos);
return TRUE;
}
+
FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) {
if (size.x < 1) {
return FALSE;
@@ -1035,15 +1035,13 @@ FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) {
FX_FLOAT fLinePos = 0;
Loader(size, fLinePos, TRUE);
UpdateAlign(size.y, fLinePos);
- if (m_pTabstopContext) {
- delete m_pTabstopContext;
- m_pTabstopContext = NULL;
- }
- if (fHeight) {
+ delete m_pTabstopContext;
+ m_pTabstopContext = nullptr;
+ if (fHeight)
*fHeight = fLinePos;
- }
return TRUE;
}
+
FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) {
if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) {
return FALSE;
diff --git a/xfa/fxfa/parser/xfa_document_imp.cpp b/xfa/fxfa/parser/xfa_document_imp.cpp
index ad3fd70e0d..083fe24a7e 100644
--- a/xfa/fxfa/parser/xfa_document_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_imp.cpp
@@ -45,44 +45,31 @@ CXFA_Document::~CXFA_Document() {
delete m_pRootNode;
PurgeNodes();
}
+
void CXFA_Document::ClearLayoutData() {
- if (m_pLayoutProcessor) {
- delete m_pLayoutProcessor;
- m_pLayoutProcessor = NULL;
- }
+ delete m_pLayoutProcessor;
+ m_pLayoutProcessor = nullptr;
+
if (m_pScriptContext) {
m_pScriptContext->Release();
- m_pScriptContext = NULL;
- }
- if (m_pLocalMgr) {
- delete m_pLocalMgr;
- m_pLocalMgr = NULL;
- }
- if (m_pScriptDataWindow) {
- delete m_pScriptDataWindow;
- m_pScriptDataWindow = NULL;
- }
- if (m_pScriptEvent) {
- delete m_pScriptEvent;
- m_pScriptEvent = NULL;
- }
- if (m_pScriptHost) {
- delete m_pScriptHost;
- m_pScriptHost = NULL;
- }
- if (m_pScriptLog) {
- delete m_pScriptLog;
- m_pScriptLog = NULL;
- }
- if (m_pScriptLayout) {
- delete m_pScriptLayout;
- m_pScriptLayout = NULL;
- }
- if (m_pScriptSignature) {
- delete m_pScriptSignature;
- m_pScriptSignature = NULL;
- }
+ m_pScriptContext = nullptr;
+ }
+ delete m_pLocalMgr;
+ m_pLocalMgr = nullptr;
+ delete m_pScriptDataWindow;
+ m_pScriptDataWindow = nullptr;
+ delete m_pScriptEvent;
+ m_pScriptEvent = nullptr;
+ delete m_pScriptHost;
+ m_pScriptHost = nullptr;
+ delete m_pScriptLog;
+ m_pScriptLog = nullptr;
+ delete m_pScriptLayout;
+ m_pScriptLayout = nullptr;
+ delete m_pScriptSignature;
+ m_pScriptSignature = nullptr;
}
+
void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) {
if (m_pRootNode) {
AddPurgeNode(m_pRootNode);
diff --git a/xfa/fxfa/parser/xfa_document_layout_imp.cpp b/xfa/fxfa/parser/xfa_document_layout_imp.cpp
index 9b9a879d4d..44d053b8c2 100644
--- a/xfa/fxfa/parser/xfa_document_layout_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_layout_imp.cpp
@@ -42,14 +42,13 @@ CXFA_LayoutProcessor::~CXFA_LayoutProcessor() {
CXFA_Document* CXFA_LayoutProcessor::GetDocument() const {
return m_pDocument;
}
+
int32_t CXFA_LayoutProcessor::StartLayout(FX_BOOL bForceRestart) {
- if (!bForceRestart && !IsNeedLayout()) {
+ if (!bForceRestart && !IsNeedLayout())
return 100;
- }
- if (m_pRootItemLayoutProcessor) {
- delete m_pRootItemLayoutProcessor;
- m_pRootItemLayoutProcessor = NULL;
- }
+
+ delete m_pRootItemLayoutProcessor;
+ m_pRootItemLayoutProcessor = nullptr;
m_nProgressCounter = 0;
CXFA_Node* pFormPacketNode =
ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form));
@@ -147,17 +146,15 @@ void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) {
CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetRootLayoutItem() const {
return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetRootLayoutItem() : NULL;
}
+
void CXFA_LayoutProcessor::ClearLayoutData() {
- if (m_pLayoutPageMgr) {
- delete m_pLayoutPageMgr;
- m_pLayoutPageMgr = NULL;
- }
- if (m_pRootItemLayoutProcessor) {
- delete m_pRootItemLayoutProcessor;
- m_pRootItemLayoutProcessor = NULL;
- }
+ delete m_pLayoutPageMgr;
+ m_pLayoutPageMgr = nullptr;
+ delete m_pRootItemLayoutProcessor;
+ m_pRootItemLayoutProcessor = nullptr;
m_nProgressCounter = 0;
}
+
FX_BOOL CXFA_LayoutProcessor::IsNeedLayout() {
return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0;
}
diff --git a/xfa/fxfa/parser/xfa_locale.cpp b/xfa/fxfa/parser/xfa_locale.cpp
index ee6d289a25..ff0371bc88 100644
--- a/xfa/fxfa/parser/xfa_locale.cpp
+++ b/xfa/fxfa/parser/xfa_locale.cpp
@@ -21,14 +21,13 @@ static const FX_WCHAR g_FX_Currency[] = L"$z,zzz,zzz,zzz,zzz,zz9.99";
static const FX_WCHAR g_FX_Decimal[] = L"z,zzz,zzz,zzz,zzz,zz9.zzz";
static const FX_WCHAR g_FX_Integer[] = L"z,zzz,zzz,zzz,zzz,zzz";
-CXFA_XMLLocale::CXFA_XMLLocale(CXML_Element* pLocaleData) {
- m_pLocaleData = pLocaleData;
-}
+CXFA_XMLLocale::CXFA_XMLLocale(CXML_Element* pLocaleData)
+ : m_pLocaleData(pLocaleData) {}
+
CXFA_XMLLocale::~CXFA_XMLLocale() {
- if (m_pLocaleData) {
- delete m_pLocaleData;
- }
+ delete m_pLocaleData;
}
+
void CXFA_XMLLocale::Release() {
delete this;
}
diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp
index 7eef2bd403..23a8dbc925 100644
--- a/xfa/fxfa/parser/xfa_parser_imp.cpp
+++ b/xfa/fxfa/parser/xfa_parser_imp.cpp
@@ -1390,13 +1390,13 @@ void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode,
m_pDocument->SetRoot(pRootNode);
}
}
+
void CXFA_DocumentParser::CloseParser() {
- if (m_pDocument) {
- delete m_pDocument;
- m_pDocument = NULL;
- }
+ delete m_pDocument;
+ m_pDocument = nullptr;
m_nodeParser.CloseParser();
}
+
CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream)
: m_nElementStart(0),
m_dwCheckStatus(0),
diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp
index ea16fd1e7c..1cd5689045 100644
--- a/xfa/fxfa/parser/xfa_script_imp.cpp
+++ b/xfa/fxfa/parser/xfa_script_imp.cpp
@@ -53,10 +53,7 @@ CXFA_ScriptContext::~CXFA_ScriptContext() {
FXJSE_Context_Release(m_hJsContext);
m_hJsContext = NULL;
}
- if (m_pResolveProcessor) {
- delete m_pResolveProcessor;
- m_pResolveProcessor = NULL;
- }
+ delete m_pResolveProcessor;
m_upObjectArray.RemoveAll();
for (int32_t i = 0; i < m_CacheListArray.GetSize(); i++)
delete m_CacheListArray[i];
@@ -398,29 +395,29 @@ void CXFA_ScriptContext::DefineJsContext() {
FXJSE_HCONTEXT CXFA_ScriptContext::CreateVariablesContext(
CXFA_Node* pScriptNode,
CXFA_Node* pSubform) {
- if (pScriptNode == NULL || pSubform == NULL) {
- return NULL;
- }
+ if (!pScriptNode || !pSubform)
+ return nullptr;
+
if (m_mapVariableToHValue.GetCount() == 0) {
- m_JsGlobalVariablesClass.constructor = NULL;
+ m_JsGlobalVariablesClass.constructor = nullptr;
m_JsGlobalVariablesClass.name = "XFAScriptObject";
m_JsGlobalVariablesClass.propNum = 0;
- m_JsGlobalVariablesClass.properties = NULL;
+ m_JsGlobalVariablesClass.properties = nullptr;
m_JsGlobalVariablesClass.methNum = 0;
- m_JsGlobalVariablesClass.methods = NULL;
+ m_JsGlobalVariablesClass.methods = nullptr;
m_JsGlobalVariablesClass.dynPropGetter =
CXFA_ScriptContext::GlobalPropertyGetter;
m_JsGlobalVariablesClass.dynPropSetter =
CXFA_ScriptContext::GlobalPropertySetter;
m_JsGlobalVariablesClass.dynPropTypeGetter =
CXFA_ScriptContext::NormalPropTypeGetter;
- m_JsGlobalVariablesClass.dynPropDeleter = NULL;
+ m_JsGlobalVariablesClass.dynPropDeleter = nullptr;
m_JsGlobalVariablesClass.dynMethodCall =
CXFA_ScriptContext::NormalMethodCall;
}
- CXFA_ThisProxy* lpVariableNode = new CXFA_ThisProxy(pSubform, pScriptNode);
- FXJSE_HCONTEXT hVariablesContext = FXJSE_Context_Create(
- m_hJsRuntime, &m_JsGlobalVariablesClass, (CXFA_Object*)lpVariableNode);
+ FXJSE_HCONTEXT hVariablesContext =
+ FXJSE_Context_Create(m_hJsRuntime, &m_JsGlobalVariablesClass,
+ new CXFA_ThisProxy(pSubform, pScriptNode));
RemoveBuiltInObjs(hVariablesContext);
FXJSE_Context_EnableCompatibleMode(
hVariablesContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS);
@@ -435,97 +432,96 @@ CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject,
}
return pObject;
}
+
FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) {
- if (pScriptNode == NULL) {
+ if (!pScriptNode)
return FALSE;
- }
- if (pScriptNode->GetClassID() == XFA_ELEMENT_Script) {
- CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (!pParent || pParent->GetClassID() != XFA_ELEMENT_Variables) {
- return FALSE;
- }
- if (m_mapVariableToHValue.GetValueAt(pScriptNode)) {
- return TRUE;
- }
- CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pTextNode) {
- return FALSE;
- }
- CFX_WideStringC wsScript;
- if (!pTextNode->TryCData(XFA_ATTRIBUTE_Value, wsScript)) {
- return FALSE;
- }
- CFX_ByteString btScript =
- FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength());
- FXJSE_HVALUE hRetValue = FXJSE_Value_Create(m_hJsRuntime);
- CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent);
- FXJSE_HCONTEXT hVariablesContext =
- CreateVariablesContext(pScriptNode, pThisObject);
- CXFA_Object* pOriginalObject = m_pThisObject;
- m_pThisObject = pThisObject;
- FX_BOOL bRet =
- FXJSE_ExecuteScript(hVariablesContext, btScript.c_str(), hRetValue);
- m_pThisObject = pOriginalObject;
- FXJSE_Value_Release(hRetValue);
- return bRet;
- }
- return TRUE;
+
+ if (pScriptNode->GetClassID() != XFA_ELEMENT_Script)
+ return TRUE;
+
+ CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
+ if (!pParent || pParent->GetClassID() != XFA_ELEMENT_Variables)
+ return FALSE;
+
+ if (m_mapVariableToHValue.GetValueAt(pScriptNode))
+ return TRUE;
+
+ CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ if (!pTextNode)
+ return FALSE;
+
+ CFX_WideStringC wsScript;
+ if (!pTextNode->TryCData(XFA_ATTRIBUTE_Value, wsScript))
+ return FALSE;
+
+ CFX_ByteString btScript =
+ FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength());
+ FXJSE_HVALUE hRetValue = FXJSE_Value_Create(m_hJsRuntime);
+ CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent);
+ FXJSE_HCONTEXT hVariablesContext =
+ CreateVariablesContext(pScriptNode, pThisObject);
+ CXFA_Object* pOriginalObject = m_pThisObject;
+ m_pThisObject = pThisObject;
+ FX_BOOL bRet =
+ FXJSE_ExecuteScript(hVariablesContext, btScript.c_str(), hRetValue);
+ m_pThisObject = pOriginalObject;
+ FXJSE_Value_Release(hRetValue);
+ return bRet;
}
+
FX_BOOL CXFA_ScriptContext::QueryVariableHValue(
CXFA_Node* pScriptNode,
const CFX_ByteStringC& szPropName,
FXJSE_HVALUE hValue,
FX_BOOL bGetter) {
- if (!pScriptNode || pScriptNode->GetClassID() != XFA_ELEMENT_Script) {
+ if (!pScriptNode || pScriptNode->GetClassID() != XFA_ELEMENT_Script)
return FALSE;
- }
+
CXFA_Node* variablesNode = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (!variablesNode || variablesNode->GetClassID() != XFA_ELEMENT_Variables) {
+ if (!variablesNode || variablesNode->GetClassID() != XFA_ELEMENT_Variables)
return FALSE;
- }
- FX_BOOL bRes = FALSE;
+
void* lpVariables = m_mapVariableToHValue.GetValueAt(pScriptNode);
- if (lpVariables) {
- FXJSE_HCONTEXT hVariableContext = (FXJSE_HCONTEXT)lpVariables;
- FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext);
- FXJSE_HVALUE hVariableValue = FXJSE_Value_Create(m_hJsRuntime);
- if (!bGetter) {
- FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue);
- bRes = TRUE;
- } else if (FXJSE_Value_ObjectHasOwnProp(hObject, szPropName, FALSE)) {
- FXJSE_Value_GetObjectProp(hObject, szPropName, hVariableValue);
- if (FXJSE_Value_IsFunction(hVariableValue)) {
- FXJSE_Value_SetFunctionBind(hValue, hVariableValue, hObject);
- } else if (bGetter) {
- FXJSE_Value_Set(hValue, hVariableValue);
- } else {
- FXJSE_Value_Set(hVariableValue, hValue);
- }
- bRes = TRUE;
- }
- FXJSE_Value_Release(hVariableValue);
- FXJSE_Value_Release(hObject);
- }
+ if (!lpVariables)
+ return FALSE;
+
+ FX_BOOL bRes = FALSE;
+ FXJSE_HCONTEXT hVariableContext = (FXJSE_HCONTEXT)lpVariables;
+ FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext);
+ FXJSE_HVALUE hVariableValue = FXJSE_Value_Create(m_hJsRuntime);
+ if (!bGetter) {
+ FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue);
+ bRes = TRUE;
+ } else if (FXJSE_Value_ObjectHasOwnProp(hObject, szPropName, FALSE)) {
+ FXJSE_Value_GetObjectProp(hObject, szPropName, hVariableValue);
+ if (FXJSE_Value_IsFunction(hVariableValue))
+ FXJSE_Value_SetFunctionBind(hValue, hVariableValue, hObject);
+ else if (bGetter)
+ FXJSE_Value_Set(hValue, hVariableValue);
+ else
+ FXJSE_Value_Set(hVariableValue, hValue);
+ bRes = TRUE;
+ }
+ FXJSE_Value_Release(hVariableValue);
+ FXJSE_Value_Release(hObject);
return bRes;
}
+
void CXFA_ScriptContext::ReleaseVariablesMap() {
FX_POSITION ps = m_mapVariableToHValue.GetStartPosition();
while (ps) {
CXFA_Object* pScriptNode;
- FXJSE_HCONTEXT hVariableContext;
+ FXJSE_HCONTEXT hVariableContext = nullptr;
m_mapVariableToHValue.GetNextAssoc(ps, pScriptNode, hVariableContext);
FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext);
- CXFA_Object* lpCurNode = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
- if (lpCurNode) {
- delete (CXFA_ThisProxy*)lpCurNode;
- lpCurNode = NULL;
- }
+ delete static_cast<CXFA_ThisProxy*>(FXJSE_Value_ToObject(hObject, nullptr));
FXJSE_Value_Release(hObject);
FXJSE_Context_Release(hVariableContext);
- hVariableContext = NULL;
}
m_mapVariableToHValue.RemoveAll();
}
+
void CXFA_ScriptContext::DefineJsClass() {
m_JsNormalClass.constructor = NULL;
m_JsNormalClass.name = "XFAObject";
diff --git a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp
index 6ea1a331c1..fa21a50b3e 100644
--- a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp
+++ b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp
@@ -19,15 +19,12 @@
#include "xfa/fxfa/parser/xfa_utils.h"
CXFA_ResolveProcessor::CXFA_ResolveProcessor(void)
- : m_pNodeHelper(NULL), m_iCurStart(0) {
- m_pNodeHelper = new CXFA_NodeHelper;
-}
+ : m_pNodeHelper(new CXFA_NodeHelper), m_iCurStart(0) {}
+
CXFA_ResolveProcessor::~CXFA_ResolveProcessor(void) {
- if (m_pNodeHelper) {
- delete m_pNodeHelper;
- m_pNodeHelper = NULL;
- }
+ delete m_pNodeHelper;
}
+
int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) {
if (rnd.m_CurNode == NULL) {
return -1;