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

Side by Side Diff: fxjs/cfxjse_runtimedata.cpp

Issue 2254123004: Fix leaked array buffer allocators of isolates (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comment Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « fxjs/cfxjse_isolatetracker.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fxjs/cfxjse_runtimedata.h" 7 #include "fxjs/cfxjse_runtimedata.h"
8 8
9 #include "fxjs/cfxjse_isolatetracker.h" 9 #include "fxjs/cfxjse_isolatetracker.h"
10 #include "fxjs/include/fxjs_v8.h" 10 #include "fxjs/include/fxjs_v8.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 void FXJSE_Finalize() { 49 void FXJSE_Finalize() {
50 if (!CFXJSE_IsolateTracker::g_pInstance) 50 if (!CFXJSE_IsolateTracker::g_pInstance)
51 return; 51 return;
52 52
53 CFXJSE_IsolateTracker::g_pInstance->RemoveAll(Runtime_DisposeCallback); 53 CFXJSE_IsolateTracker::g_pInstance->RemoveAll(Runtime_DisposeCallback);
54 delete CFXJSE_IsolateTracker::g_pInstance; 54 delete CFXJSE_IsolateTracker::g_pInstance;
55 CFXJSE_IsolateTracker::g_pInstance = nullptr; 55 CFXJSE_IsolateTracker::g_pInstance = nullptr;
56 } 56 }
57 57
58 v8::Isolate* FXJSE_Runtime_Create_Own() { 58 v8::Isolate* FXJSE_Runtime_Create_Own() {
59 std::unique_ptr<v8::ArrayBuffer::Allocator> allocator(
60 new FXJSE_ArrayBufferAllocator());
59 v8::Isolate::CreateParams params; 61 v8::Isolate::CreateParams params;
60 params.array_buffer_allocator = new FXJSE_ArrayBufferAllocator(); 62 params.array_buffer_allocator = allocator.get();
61 v8::Isolate* pIsolate = v8::Isolate::New(params); 63 v8::Isolate* pIsolate = v8::Isolate::New(params);
62 ASSERT(pIsolate && CFXJSE_IsolateTracker::g_pInstance); 64 ASSERT(pIsolate && CFXJSE_IsolateTracker::g_pInstance);
63 CFXJSE_IsolateTracker::g_pInstance->Append(pIsolate); 65 CFXJSE_IsolateTracker::g_pInstance->Append(pIsolate, std::move(allocator));
64 return pIsolate; 66 return pIsolate;
65 } 67 }
66 68
67 void FXJSE_Runtime_Release(v8::Isolate* pIsolate) { 69 void FXJSE_Runtime_Release(v8::Isolate* pIsolate) {
68 if (!pIsolate) 70 if (!pIsolate)
69 return; 71 return;
70 CFXJSE_IsolateTracker::g_pInstance->Remove(pIsolate, Runtime_DisposeCallback); 72 CFXJSE_IsolateTracker::g_pInstance->Remove(pIsolate, Runtime_DisposeCallback);
71 } 73 }
72 74
73 CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate) 75 CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate)
(...skipping 22 matching lines...) Expand all
96 98
97 CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) { 99 CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) {
98 FXJS_PerIsolateData::SetUp(pIsolate); 100 FXJS_PerIsolateData::SetUp(pIsolate);
99 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); 101 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate);
100 if (!pData->m_pFXJSERuntimeData) 102 if (!pData->m_pFXJSERuntimeData)
101 pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate); 103 pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate);
102 return pData->m_pFXJSERuntimeData; 104 return pData->m_pFXJSERuntimeData;
103 } 105 }
104 106
105 CFXJSE_IsolateTracker* CFXJSE_IsolateTracker::g_pInstance = nullptr; 107 CFXJSE_IsolateTracker* CFXJSE_IsolateTracker::g_pInstance = nullptr;
OLDNEW
« no previous file with comments | « fxjs/cfxjse_isolatetracker.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698