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

Side by Side Diff: src/d8.cc

Issue 1197403002: Global handle leak in Realm.create() fixed. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | test/mjsunit/regress/regress-crbug-501808.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project 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 5
6 // Defined when linking against shared lib on Windows. 6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED 8 #define V8_SHARED
9 #endif 9 #endif
10 10
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 473
474 // Realm.create() creates a new realm and returns its index. 474 // Realm.create() creates a new realm and returns its index.
475 void Shell::RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args) { 475 void Shell::RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args) {
476 Isolate* isolate = args.GetIsolate(); 476 Isolate* isolate = args.GetIsolate();
477 PerIsolateData* data = PerIsolateData::Get(isolate); 477 PerIsolateData* data = PerIsolateData::Get(isolate);
478 Persistent<Context>* old_realms = data->realms_; 478 Persistent<Context>* old_realms = data->realms_;
479 int index = data->realm_count_; 479 int index = data->realm_count_;
480 data->realms_ = new Persistent<Context>[++data->realm_count_]; 480 data->realms_ = new Persistent<Context>[++data->realm_count_];
481 for (int i = 0; i < index; ++i) { 481 for (int i = 0; i < index; ++i) {
482 data->realms_[i].Reset(isolate, old_realms[i]); 482 data->realms_[i].Reset(isolate, old_realms[i]);
483 old_realms[i].Reset();
483 } 484 }
484 delete[] old_realms; 485 delete[] old_realms;
485 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); 486 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
486 data->realms_[index].Reset( 487 data->realms_[index].Reset(
487 isolate, Context::New(isolate, NULL, global_template)); 488 isolate, Context::New(isolate, NULL, global_template));
488 args.GetReturnValue().Set(index); 489 args.GetReturnValue().Set(index);
489 } 490 }
490 491
491 492
492 // Realm.dispose(i) disposes the reference to the realm i. 493 // Realm.dispose(i) disposes the reference to the realm i.
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 } 1756 }
1756 1757
1757 } // namespace v8 1758 } // namespace v8
1758 1759
1759 1760
1760 #ifndef GOOGLE3 1761 #ifndef GOOGLE3
1761 int main(int argc, char* argv[]) { 1762 int main(int argc, char* argv[]) {
1762 return v8::Shell::Main(argc, argv); 1763 return v8::Shell::Main(argc, argv);
1763 } 1764 }
1764 #endif 1765 #endif
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-501808.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698