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

Unified Diff: fxjs/cfxjse_runtimedata.cpp

Issue 2354923003: Fix leaks related to the usage of JSE runtime data (Closed)
Patch Set: Created 4 years, 3 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 | « fxjs/cfxjse_runtimedata.h ('k') | fxjs/fxjs_v8.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fxjs/cfxjse_runtimedata.cpp
diff --git a/fxjs/cfxjse_runtimedata.cpp b/fxjs/cfxjse_runtimedata.cpp
index 2c9379526e40c2e044b0864907142dd71f24e516..021fb1dbe4324e0a787a6ff9b043e57849b69a92 100644
--- a/fxjs/cfxjse_runtimedata.cpp
+++ b/fxjs/cfxjse_runtimedata.cpp
@@ -20,10 +20,8 @@ class FXJSE_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
};
void Runtime_DisposeCallback(v8::Isolate* pIsolate, bool bOwned) {
- if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) {
- delete pData->m_pFXJSERuntimeData;
- pData->m_pFXJSERuntimeData = nullptr;
- }
+ if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate))
+ delete pData;
if (bOwned)
pIsolate->Dispose();
}
@@ -77,8 +75,10 @@ CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate)
CFXJSE_RuntimeData::~CFXJSE_RuntimeData() {}
-CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) {
- CFXJSE_RuntimeData* pRuntimeData = new CFXJSE_RuntimeData(pIsolate);
+std::unique_ptr<CFXJSE_RuntimeData> CFXJSE_RuntimeData::Create(
+ v8::Isolate* pIsolate) {
+ std::unique_ptr<CFXJSE_RuntimeData> pRuntimeData(
+ new CFXJSE_RuntimeData(pIsolate));
CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate);
v8::Local<v8::FunctionTemplate> hFuncTemplate =
v8::FunctionTemplate::New(pIsolate);
@@ -101,7 +101,7 @@ CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) {
FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate);
if (!pData->m_pFXJSERuntimeData)
pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate);
- return pData->m_pFXJSERuntimeData;
+ return pData->m_pFXJSERuntimeData.get();
}
CFXJSE_IsolateTracker* CFXJSE_IsolateTracker::g_pInstance = nullptr;
« no previous file with comments | « fxjs/cfxjse_runtimedata.h ('k') | fxjs/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698