summaryrefslogtreecommitdiff
path: root/xfa/fxjse/context.cpp
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/fxjse/context.cpp
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/fxjse/context.cpp')
-rw-r--r--xfa/fxjse/context.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/xfa/fxjse/context.cpp b/xfa/fxjse/context.cpp
index abb30c5dc5..9a6b9120a2 100644
--- a/xfa/fxjse/context.cpp
+++ b/xfa/fxjse/context.cpp
@@ -11,6 +11,14 @@
#include "xfa/fxjse/util_inline.h"
#include "xfa/fxjse/value.h"
+namespace {
+
+CFXJSE_Context* CFXContextFromHContext(FXJSE_HCONTEXT hContext) {
+ return reinterpret_cast<CFXJSE_Context*>(hContext);
+}
+
+} // namespace
+
FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime,
const FXJSE_CLASS* lpGlobalClass,
void* lpGlobalObject) {
@@ -20,17 +28,14 @@ FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime,
}
void FXJSE_Context_Release(FXJSE_HCONTEXT hContext) {
- CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext);
- if (pContext) {
- delete pContext;
- }
+ delete CFXContextFromHContext(hContext);
}
FXJSE_HVALUE FXJSE_Context_GetGlobalObject(FXJSE_HCONTEXT hContext) {
- CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext);
- if (!pContext) {
- return NULL;
- }
+ CFXJSE_Context* pContext = CFXContextFromHContext(hContext);
+ if (!pContext)
+ return nullptr;
+
CFXJSE_Value* lpValue = CFXJSE_Value::Create(pContext->GetRuntime());
ASSERT(lpValue);
pContext->GetGlobalObject(lpValue);
@@ -76,8 +81,7 @@ FX_BOOL FXJSE_ExecuteScript(FXJSE_HCONTEXT hContext,
const FX_CHAR* szScript,
FXJSE_HVALUE hRetValue,
FXJSE_HVALUE hNewThisObject) {
- CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext);
- ASSERT(pContext);
+ CFXJSE_Context* pContext = CFXContextFromHContext(hContext);
return pContext->ExecuteScript(
szScript, reinterpret_cast<CFXJSE_Value*>(hRetValue),
reinterpret_cast<CFXJSE_Value*>(hNewThisObject));
@@ -152,12 +156,8 @@ CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate,
}
CFXJSE_Context::~CFXJSE_Context() {
- for (int32_t i = 0, count = m_rgClasses.GetSize(); i < count; i++) {
- CFXJSE_Class* pClass = m_rgClasses[i];
- if (pClass) {
- delete pClass;
- }
- }
+ for (int32_t i = 0, count = m_rgClasses.GetSize(); i < count; i++)
+ delete m_rgClasses[i];
m_rgClasses.RemoveAll();
}