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

Unified Diff: samples/shell.cc

Issue 9959014: Fix scoping of v8::HandleScope to prevent use-after-dispose (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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: samples/shell.cc
diff --git a/samples/shell.cc b/samples/shell.cc
index b40eca2f7c0b696411e0db9b4d4101100d0baf50..db0cc1a930aa22a21b82a887fb362b1b8bc65944 100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -67,17 +67,20 @@ static bool run_shell;
int main(int argc, char* argv[]) {
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
run_shell = (argc == 1);
- v8::HandleScope handle_scope;
- v8::Persistent<v8::Context> context = CreateShellContext();
- if (context.IsEmpty()) {
- printf("Error creating context\n");
- return 1;
+ int result;
+ {
+ v8::HandleScope handle_scope;
+ v8::Persistent<v8::Context> context = CreateShellContext();
+ if (context.IsEmpty()) {
+ printf("Error creating context\n");
+ return 1;
+ }
+ context->Enter();
+ result = RunMain(argc, argv);
+ if (run_shell) RunShell(context);
+ context->Exit();
+ context.Dispose();
}
- context->Enter();
- int result = RunMain(argc, argv);
- if (run_shell) RunShell(context);
- context->Exit();
- context.Dispose();
v8::V8::Dispose();
return result;
}
« 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