Commit b063b2d7 authored by danno@chromium.org's avatar danno@chromium.org

Fix scoping of v8::HandleScope to prevent use-after-dispose

R=jkummerow@chromium.org
TEST=shell_g doesn't crash

Review URL: https://chromiumcodereview.appspot.com/9959014

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11195 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8360ec87
// 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 // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -67,6 +67,8 @@ static bool run_shell; ...@@ -67,6 +67,8 @@ static bool run_shell;
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::SetFlagsFromCommandLine(&argc, argv, true); v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
run_shell = (argc == 1); run_shell = (argc == 1);
int result;
{
v8::HandleScope handle_scope; v8::HandleScope handle_scope;
v8::Persistent<v8::Context> context = CreateShellContext(); v8::Persistent<v8::Context> context = CreateShellContext();
if (context.IsEmpty()) { if (context.IsEmpty()) {
...@@ -74,10 +76,11 @@ int main(int argc, char* argv[]) { ...@@ -74,10 +76,11 @@ int main(int argc, char* argv[]) {
return 1; return 1;
} }
context->Enter(); context->Enter();
int result = RunMain(argc, argv); result = RunMain(argc, argv);
if (run_shell) RunShell(context); if (run_shell) RunShell(context);
context->Exit(); context->Exit();
context.Dispose(); context.Dispose();
}
v8::V8::Dispose(); v8::V8::Dispose();
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment