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

Unified Diff: runtime/bin/process_macos.cc

Issue 8659032: Fix memory leak in MacOS process handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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
Index: runtime/bin/process_macos.cc
diff --git a/runtime/bin/process_macos.cc b/runtime/bin/process_macos.cc
index 9a1d178864d969416f65c13f7c5bb362f323e9c1..0fc3ef5223be27f7eee9c29338f9282736fe507d 100644
--- a/runtime/bin/process_macos.cc
+++ b/runtime/bin/process_macos.cc
@@ -52,7 +52,7 @@ static ProcessInfo* LookupProcess(pid_t pid) {
}
-static ProcessInfo* RemoveProcess(pid_t pid) {
+static void RemoveProcess(pid_t pid) {
ProcessInfo* prev = NULL;
ProcessInfo* current = active_processes;
while (current != NULL) {
@@ -62,12 +62,12 @@ static ProcessInfo* RemoveProcess(pid_t pid) {
} else {
prev->set_next(current->next());
}
- return current;
+ delete current;
+ return;
}
prev = current;
current = current->next();
}
- return NULL;
}
@@ -230,13 +230,19 @@ int Process::Start(const char* path,
close(read_err[0]);
close(exec_control[0]);
- dup2(write_out[0], STDIN_FILENO);
+ if (dup2(write_out[0], STDIN_FILENO) == -1) {
Søren Gjesse 2011/11/29 09:39:25 Ditto.
Mads Ager (google) 2011/11/29 10:10:13 Done.
+ perror("Failed to dup stdin");
+ }
close(write_out[0]);
- dup2(read_in[1], STDOUT_FILENO);
+ if (dup2(read_in[1], STDOUT_FILENO) == -1) {
+ perror("Failed to dup stdout");
+ }
close(read_in[1]);
- dup2(read_err[1], STDERR_FILENO);
+ if (dup2(read_err[1], STDERR_FILENO) == -1) {
+ perror("Failed to dup stderr");
+ }
close(read_err[1]);
execvp(path, const_cast<char* const*>(program_arguments));

Powered by Google App Engine
This is Rietveld 408576698