Skip to content

Commit

Permalink
Fixed segfault if main script has a compile error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Schwartz committed Jun 20, 2012
1 parent 32c3c66 commit cd89b51
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main.cpp
Expand Up @@ -136,10 +136,13 @@ int main (int argc, char** argv) {

Handle<Script>init = Script::New(String::New("global=this; module = {}; include('builtin/all.js');"), String::New("builtin"));
init->Run();

mainScript = Persistent<Script>::New(Script::Compile(String::New(startup), String::New(progName)));
V8::SetCaptureStackTraceForUncaughtExceptions(true, 50, StackTrace::kDetailed);
TryCatch tryCatch;
mainScript = Persistent<Script>::New(Script::Compile(String::New(startup), String::New(progName)));
if (mainScript.IsEmpty()) {
ReportException(&tryCatch);
exit(1);
}
Handle<Value>v = mainScript->Run();
if (v.IsEmpty()) {
ReportException(&tryCatch);
Expand Down

0 comments on commit cd89b51

Please sign in to comment.