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

Unified Diff: runtime/bin/process.cc

Issue 1665993002: Prefer Dart_SetReturnValue over Dart_PropagateError when it makes sense. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « runtime/bin/file_system_watcher.cc ('k') | runtime/bin/socket.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process.cc
diff --git a/runtime/bin/process.cc b/runtime/bin/process.cc
index f9d345735e38827a2d9e9ae55d1d0152fbcf73a7..b58304952cd4193e4ffcb88bbc0b5bd19a35c419 100644
--- a/runtime/bin/process.cc
+++ b/runtime/bin/process.cc
@@ -188,6 +188,9 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
os_error_message != NULL ? os_error_message
: "Cannot get error message");
if (Dart_IsError(result)) {
+ delete[] string_args;
+ delete[] string_environment;
+ free(os_error_message);
Dart_PropagateError(result);
}
}
@@ -230,7 +233,6 @@ void FUNCTION_NAME(Process_Wait)(Dart_NativeArguments args) {
} else {
Dart_Handle error = DartUtils::NewDartOSError();
Process::Kill(pid, 9);
- if (Dart_IsError(error)) Dart_PropagateError(error);
Dart_ThrowException(error);
}
}
@@ -340,7 +342,6 @@ void FUNCTION_NAME(SystemEncodingToString)(Dart_NativeArguments args) {
result =
Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str), len);
free(str);
- if (Dart_IsError(result)) Dart_PropagateError(result);
Dart_SetReturnValue(args, result);
}
@@ -363,13 +364,11 @@ void FUNCTION_NAME(StringToSystemEncoding)(Dart_NativeArguments args) {
}
uint8_t* buffer = NULL;
Dart_Handle external_array = IOBuffer::Allocate(system_len, &buffer);
- if (Dart_IsError(external_array)) {
- free(const_cast<char*>(system_string));
- Dart_PropagateError(result);
+ if (!Dart_IsError(external_array)) {
+ memmove(buffer, system_string, system_len);
}
- memmove(buffer, system_string, system_len);
- free(const_cast<char*>(system_string));
Dart_SetReturnValue(args, external_array);
+ free(const_cast<char*>(system_string));
}
} // namespace bin
« no previous file with comments | « runtime/bin/file_system_watcher.cc ('k') | runtime/bin/socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698