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

Unified Diff: runtime/bin/process_android.cc

Issue 1781883002: Fixes some memory leaks in //runtime/bin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix tests on Windows Created 4 years, 9 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/process.cc ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_android.cc
diff --git a/runtime/bin/process_android.cc b/runtime/bin/process_android.cc
index b9d245bbb888e8e0051c7f1c6da252de79d1791c..6f2394dd14ffecc7df57bb607c2c80d3aaa5ffc6 100644
--- a/runtime/bin/process_android.cc
+++ b/runtime/bin/process_android.cc
@@ -16,6 +16,7 @@
#include <sys/wait.h> // NOLINT
#include <unistd.h> // NOLINT
+#include "bin/dartutils.h"
#include "bin/fdutils.h"
#include "bin/lockers.h"
#include "bin/log.h"
@@ -635,7 +636,9 @@ class ProcessStarter {
int actual_errno = errno;
// If CleanupAndReturnError is called without an actual errno make
// sure to return an error anyway.
- if (actual_errno == 0) actual_errno = EPERM;
+ if (actual_errno == 0) {
+ actual_errno = EPERM;
+ }
SetChildOsErrorMessage();
CloseAllPipes();
return actual_errno;
@@ -644,9 +647,9 @@ class ProcessStarter {
void SetChildOsErrorMessage() {
const int kBufferSize = 1024;
- char error_message[kBufferSize];
+ char* error_message = DartUtils::ScopedCString(kBufferSize);
Utils::StrError(errno, error_message, kBufferSize);
- *os_error_message_ = strdup(error_message);
+ *os_error_message_ = error_message;
}
@@ -681,7 +684,7 @@ class ProcessStarter {
void ReadChildError() {
const int kMaxMessageSize = 256;
- char* message = static_cast<char*>(malloc(kMaxMessageSize));
+ char* message = DartUtils::ScopedCString(kMaxMessageSize);
if (message != NULL) {
FDUtils::ReadFromBlocking(exec_control_[0], message, kMaxMessageSize);
message[kMaxMessageSize - 1] = '\0';
« no previous file with comments | « runtime/bin/process.cc ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698