Index: runtime/bin/process.cc |
diff --git a/runtime/bin/process.cc b/runtime/bin/process.cc |
index b58304952cd4193e4ffcb88bbc0b5bd19a35c419..9c9ed94e7574c3b8c6f101b1c383bb9fccd7723a 100644 |
--- a/runtime/bin/process.cc |
+++ b/runtime/bin/process.cc |
@@ -151,7 +151,7 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) { |
Dart_Handle stderr_handle = Dart_GetNativeArgument(args, 8); |
Dart_Handle exit_handle = Dart_GetNativeArgument(args, 9); |
intptr_t pid = -1; |
- char* os_error_message = NULL; |
+ char* os_error_message = NULL; // Scope allocated by Process::Start. |
int error_code = Process::Start(path, |
string_args, |
@@ -190,13 +190,11 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) { |
if (Dart_IsError(result)) { |
delete[] string_args; |
delete[] string_environment; |
- free(os_error_message); |
Dart_PropagateError(result); |
} |
} |
delete[] string_args; |
delete[] string_environment; |
- free(os_error_message); |
Dart_SetReturnValue(args, Dart_NewBoolean(error_code == 0)); |
} |
@@ -323,25 +321,24 @@ void FUNCTION_NAME(SystemEncodingToString)(Dart_NativeArguments args) { |
Dart_Handle bytes = Dart_GetNativeArgument(args, 0); |
intptr_t bytes_length = 0; |
Dart_Handle result = Dart_ListLength(bytes, &bytes_length); |
- if (Dart_IsError(result)) Dart_PropagateError(result); |
- uint8_t* buffer = |
- reinterpret_cast<uint8_t*>(Dart_ScopeAllocate(bytes_length + 1)); |
+ if (Dart_IsError(result)) { |
+ Dart_PropagateError(result); |
+ } |
+ uint8_t* buffer = Dart_ScopeAllocate(bytes_length + 1); |
result = Dart_ListGetAsBytes(bytes, 0, buffer, bytes_length); |
buffer[bytes_length] = '\0'; |
- if (Dart_IsError(result)) Dart_PropagateError(result); |
+ if (Dart_IsError(result)) { |
+ Dart_PropagateError(result); |
+ } |
intptr_t len; |
- char* str = |
- StringUtils::ConsoleStringToUtf8( |
- reinterpret_cast<char*>(buffer), |
- bytes_length, |
- &len); |
+ char* str = StringUtils::ConsoleStringToUtf8( |
+ reinterpret_cast<char*>(buffer), bytes_length, &len); |
if (str == NULL) { |
Dart_ThrowException( |
DartUtils::NewInternalError("SystemEncodingToString failed")); |
} |
result = |
Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str), len); |
- free(str); |
Dart_SetReturnValue(args, result); |
} |
@@ -368,7 +365,6 @@ void FUNCTION_NAME(StringToSystemEncoding)(Dart_NativeArguments args) { |
memmove(buffer, system_string, system_len); |
} |
Dart_SetReturnValue(args, external_array); |
- free(const_cast<char*>(system_string)); |
} |
} // namespace bin |