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

Side by Side Diff: fxjs/cfxjse_isolatetracker.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.h ('k') | fxjs/cfxjse_runtimedata.cpp » ('j') | 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_isolatetracker.h" 7 #include "fxjs/cfxjse_isolatetracker.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 CFXJSE_IsolateTracker::CFXJSE_IsolateTracker() {} 11 CFXJSE_IsolateTracker::CFXJSE_IsolateTracker() {}
12 12
13 CFXJSE_IsolateTracker::~CFXJSE_IsolateTracker() {} 13 CFXJSE_IsolateTracker::~CFXJSE_IsolateTracker() {}
14 14
15 void CFXJSE_IsolateTracker::Append(v8::Isolate* pIsolate) { 15 void CFXJSE_IsolateTracker::Append(
16 v8::Isolate* pIsolate,
17 std::unique_ptr<v8::ArrayBuffer::Allocator> alloc) {
16 m_OwnedIsolates.push_back(pIsolate); 18 m_OwnedIsolates.push_back(pIsolate);
19 m_AllocatorMap[pIsolate] = std::move(alloc);
17 } 20 }
18 21
19 void CFXJSE_IsolateTracker::Remove( 22 void CFXJSE_IsolateTracker::Remove(
20 v8::Isolate* pIsolate, 23 v8::Isolate* pIsolate,
21 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { 24 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) {
22 auto it = std::find(m_OwnedIsolates.begin(), m_OwnedIsolates.end(), pIsolate); 25 auto it = std::find(m_OwnedIsolates.begin(), m_OwnedIsolates.end(), pIsolate);
23 bool bFound = it != m_OwnedIsolates.end(); 26 bool bFound = it != m_OwnedIsolates.end();
24 if (bFound) 27 if (bFound)
25 m_OwnedIsolates.erase(it); 28 m_OwnedIsolates.erase(it);
26 lpfnDisposeCallback(pIsolate, bFound); 29 lpfnDisposeCallback(pIsolate, bFound);
30
31 m_AllocatorMap.erase(pIsolate);
27 } 32 }
28 33
29 void CFXJSE_IsolateTracker::RemoveAll( 34 void CFXJSE_IsolateTracker::RemoveAll(
30 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { 35 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) {
31 for (v8::Isolate* pIsolate : m_OwnedIsolates) 36 for (v8::Isolate* pIsolate : m_OwnedIsolates)
32 lpfnDisposeCallback(pIsolate, true); 37 lpfnDisposeCallback(pIsolate, true);
33 38
34 m_OwnedIsolates.clear(); 39 m_OwnedIsolates.clear();
40 m_AllocatorMap.clear();
35 } 41 }
OLDNEW
« no previous file with comments | « fxjs/cfxjse_isolatetracker.h ('k') | fxjs/cfxjse_runtimedata.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698