| Index: runtime/bin/main.cc
|
| diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
|
| index 8ce10b4d83ad2984ffa90dbff5af9504a2ba277e..f20c29929ebb3680a2c72e3cccde372553198480 100644
|
| --- a/runtime/bin/main.cc
|
| +++ b/runtime/bin/main.cc
|
| @@ -108,7 +108,14 @@ static void ErrorExit(int exit_code, const char* format, ...) {
|
| Dart_ExitScope();
|
| Dart_ShutdownIsolate();
|
|
|
| - Dart_Cleanup();
|
| + // Terminate process exit-code handler.
|
| + Process::TerminateExitCodeHandler();
|
| +
|
| + char* error = Dart_Cleanup();
|
| + if (error != NULL) {
|
| + Log::PrintErr("VM cleanup failed: %s\n", error);
|
| + free(error);
|
| + }
|
|
|
| exit(exit_code);
|
| }
|
| @@ -624,6 +631,7 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| error);
|
|
|
| if (isolate == NULL) {
|
| + delete isolate_data;
|
| return NULL;
|
| }
|
|
|
| @@ -1019,15 +1027,17 @@ void main(int argc, char** argv) {
|
| }
|
|
|
| // Initialize the Dart VM.
|
| - if (!Dart_Initialize(vm_isolate_snapshot_buffer,
|
| - CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate,
|
| - DartUtils::OpenFile,
|
| - DartUtils::ReadFile,
|
| - DartUtils::WriteFile,
|
| - DartUtils::CloseFile,
|
| - DartUtils::EntropySource)) {
|
| - fprintf(stderr, "%s", "VM initialization failed\n");
|
| + char* error = Dart_Initialize(vm_isolate_snapshot_buffer,
|
| + CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate,
|
| + DartUtils::OpenFile,
|
| + DartUtils::ReadFile,
|
| + DartUtils::WriteFile,
|
| + DartUtils::CloseFile,
|
| + DartUtils::EntropySource);
|
| + if (error != NULL) {
|
| + fprintf(stderr, "VM initialization failed: %s\n", error);
|
| fflush(stderr);
|
| + free(error);
|
| exit(kErrorExitCode);
|
| }
|
|
|
| @@ -1038,7 +1048,6 @@ void main(int argc, char** argv) {
|
|
|
| // Call CreateIsolateAndSetup which creates an isolate and loads up
|
| // the specified application script.
|
| - char* error = NULL;
|
| int exit_code = 0;
|
| char* isolate_name = BuildIsolateName(script_name, "main");
|
| Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name,
|
| @@ -1051,7 +1060,14 @@ void main(int argc, char** argv) {
|
| if (isolate == NULL) {
|
| Log::PrintErr("%s\n", error);
|
| free(error);
|
| + error = NULL;
|
| delete [] isolate_name;
|
| + Process::TerminateExitCodeHandler();
|
| + error = Dart_Cleanup();
|
| + if (error != NULL) {
|
| + Log::PrintErr("VM cleanup failed: %s\n", error);
|
| + free(error);
|
| + }
|
| exit((exit_code != 0) ? exit_code : kErrorExitCode);
|
| }
|
| delete [] isolate_name;
|
| @@ -1155,7 +1171,11 @@ void main(int argc, char** argv) {
|
| // Terminate process exit-code handler.
|
| Process::TerminateExitCodeHandler();
|
|
|
| - Dart_Cleanup();
|
| + error = Dart_Cleanup();
|
| + if (error != NULL) {
|
| + Log::PrintErr("VM cleanup failed: %s\n", error);
|
| + free(error);
|
| + }
|
|
|
| // Free copied argument strings if converted.
|
| if (argv_converted) {
|
|
|