Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: fpdfsdk/src/jsapi/fxjs_v8.cpp

Issue 1417973009: Fix memory leak in FXJS_ReleaseRuntime. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: cleanup and fixes Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/jsapi/fxjs_v8.cpp
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index 8a5447591058a87bd9df55189fc6d4961fe383ff..2fb3e13064e6641a3d1d227bd34074ca0df048ae 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -335,9 +335,15 @@ void FXJS_ReleaseRuntime(v8::Isolate* pIsolate,
int maxID = CFXJS_ObjDefinition::MaxID(pIsolate);
for (int i = 0; i < maxID; ++i) {
CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i);
- if (!pObjDef->m_StaticObj.IsEmpty()) {
- v8::Local<v8::Object> pObj =
- v8::Local<v8::Object>::New(pIsolate, pObjDef->m_StaticObj);
+ v8::Local<v8::Object> pObj;
+ if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) {
+ pObj =
+ context->Global()->GetPrototype()->ToObject(context).ToLocalChecked();
+ } else if (!pObjDef->m_StaticObj.IsEmpty()) {
+ pObj = v8::Local<v8::Object>::New(pIsolate, pObjDef->m_StaticObj);
+ }
+
+ if (!pObj.IsEmpty()) {
if (pObjDef->m_pDestructor)
pObjDef->m_pDestructor(pObj);
FXJS_FreePrivate(pObj);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698