- Avoid allocating variable length arrays on the stack.
- Fix C++ warning about copying vtables. - Use correct delete for PortMap entries. Review URL: http://codereview.chromium.org//8555024 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1538 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -189,7 +189,7 @@ int Process::Start(const char* path,
|
||||
return errno;
|
||||
}
|
||||
|
||||
char* program_arguments[arguments_length + 2];
|
||||
char** program_arguments = new char*[arguments_length + 2];
|
||||
program_arguments[0] = const_cast<char *>(path);
|
||||
for (int i = 0; i < arguments_length; i++) {
|
||||
program_arguments[i + 1] = arguments[i];
|
||||
@@ -206,6 +206,7 @@ int Process::Start(const char* path,
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
SetChildOsErrorMessage(os_error_message, os_error_message_len);
|
||||
delete[] program_arguments;
|
||||
close(read_in[0]);
|
||||
close(read_in[1]);
|
||||
close(read_err[0]);
|
||||
@@ -255,6 +256,9 @@ int Process::Start(const char* path,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// The arguments for the spawned process are not needed any longer.
|
||||
delete[] program_arguments;
|
||||
|
||||
int event_fds[2];
|
||||
result = pipe(event_fds);
|
||||
if (result < 0) {
|
||||
|
||||
@@ -189,7 +189,7 @@ int Process::Start(const char* path,
|
||||
return errno;
|
||||
}
|
||||
|
||||
char* program_arguments[arguments_length + 2];
|
||||
char** program_arguments = new char*[arguments_length + 2];
|
||||
program_arguments[0] = const_cast<char *>(path);
|
||||
for (int i = 0; i < arguments_length; i++) {
|
||||
program_arguments[i + 1] = arguments[i];
|
||||
@@ -206,6 +206,7 @@ int Process::Start(const char* path,
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
SetChildOsErrorMessage(os_error_message, os_error_message_len);
|
||||
delete[] program_arguments;
|
||||
close(read_in[0]);
|
||||
close(read_in[1]);
|
||||
close(read_err[0]);
|
||||
@@ -255,6 +256,9 @@ int Process::Start(const char* path,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// The arguments for the spawned process are not needed any longer.
|
||||
delete[] program_arguments;
|
||||
|
||||
int event_fds[2];
|
||||
result = pipe(event_fds);
|
||||
if (result < 0) {
|
||||
|
||||
@@ -315,7 +315,9 @@ template<class D, class S>
|
||||
inline D bit_copy(const S& source) {
|
||||
D destination;
|
||||
// This use of memcpy is safe: source and destination cannot overlap.
|
||||
memcpy(&destination, &source, sizeof(destination));
|
||||
memcpy(&destination,
|
||||
reinterpret_cast<const void*>(&source),
|
||||
sizeof(destination));
|
||||
return destination;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ void PortMap::Rehash(intptr_t new_capacity) {
|
||||
new_ports[new_index] = entry;
|
||||
}
|
||||
}
|
||||
delete map_;
|
||||
delete[] map_;
|
||||
map_ = new_ports;
|
||||
capacity_ = new_capacity;
|
||||
deleted_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user