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

Unified Diff: components/breakpad/app/breakpad_linux.cc

Issue 296553002: Breakpad Linux: Prevent some memory leaks. (Try 2) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix asan Created 6 years, 7 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
Index: components/breakpad/app/breakpad_linux.cc
===================================================================
--- components/breakpad/app/breakpad_linux.cc (revision 271470)
+++ components/breakpad/app/breakpad_linux.cc (working copy)
@@ -203,16 +203,6 @@
return len;
}
-// Populates the passed in allocated string and its size with the distro of
-// the crashing process.
-// The passed string is expected to be at least kDistroSize bytes long.
-void PopulateDistro(char* distro, size_t* distro_len_param) {
- size_t distro_len = std::min(my_strlen(base::g_linux_distro), kDistroSize);
- memcpy(distro, base::g_linux_distro, distro_len);
- if (distro_len_param)
- *distro_len_param = distro_len;
-}
-
void SetClientIdFromCommandLine(const CommandLine& command_line) {
// Get the guid and linux distro from the command line switch.
std::string switch_value =
@@ -698,16 +688,13 @@
}
// Start constructing the message to send to the browser.
- char distro[kDistroSize + 1] = {0};
- size_t distro_length = 0;
- PopulateDistro(distro, &distro_length);
BreakpadInfo info = {0};
info.filename = NULL;
info.fd = descriptor.fd();
info.process_type = g_process_type;
info.process_type_length = my_strlen(g_process_type);
- info.distro = distro;
- info.distro_length = distro_length;
+ info.distro = NULL;
+ info.distro_length = 0;
info.upload = false;
info.process_start_time = g_process_start_time;
info.pid = g_pid;
@@ -788,9 +775,6 @@
}
// Start constructing the message to send to the browser.
- char distro[kDistroSize + 1] = {0};
- PopulateDistro(distro, NULL);
-
char b; // Dummy variable for sys_read below.
const char* b_addr = &b; // Get the address of |b| so we can create the
// expected /proc/[pid]/syscall content in the
@@ -806,24 +790,25 @@
struct kernel_iovec iov[kCrashIovSize];
iov[0].iov_base = const_cast<void*>(crash_context);
iov[0].iov_len = crash_context_size;
- iov[1].iov_base = distro;
- iov[1].iov_len = kDistroSize + 1;
- iov[2].iov_base = &b_addr;
- iov[2].iov_len = sizeof(b_addr);
- iov[3].iov_base = &fds[0];
- iov[3].iov_len = sizeof(fds[0]);
- iov[4].iov_base = &g_process_start_time;
- iov[4].iov_len = sizeof(g_process_start_time);
- iov[5].iov_base = &base::g_oom_size;
- iov[5].iov_len = sizeof(base::g_oom_size);
+ iov[1].iov_base = &b_addr;
+ iov[1].iov_len = sizeof(b_addr);
+ iov[2].iov_base = &fds[0];
+ iov[2].iov_len = sizeof(fds[0]);
+ iov[3].iov_base = &g_process_start_time;
+ iov[3].iov_len = sizeof(g_process_start_time);
+ iov[4].iov_base = &base::g_oom_size;
+ iov[4].iov_len = sizeof(base::g_oom_size);
google_breakpad::SerializedNonAllocatingMap* serialized_map;
- iov[6].iov_len = g_crash_keys->Serialize(
+ iov[5].iov_len = g_crash_keys->Serialize(
const_cast<const google_breakpad::SerializedNonAllocatingMap**>(
&serialized_map));
- iov[6].iov_base = serialized_map;
-#if defined(ADDRESS_SANITIZER)
- iov[7].iov_base = const_cast<char*>(g_asan_report_str);
- iov[7].iov_len = kMaxAsanReportSize + 1;
+ iov[5].iov_base = serialized_map;
+#if !defined(ADDRESS_SANITIZER)
+ COMPILE_ASSERT(5 == kCrashIovSize - 1, Incorrect_Number_Of_Iovec_Members);
+#else
+ iov[6].iov_base = const_cast<char*>(g_asan_report_str);
+ iov[6].iov_len = kMaxAsanReportSize + 1;
+ COMPILE_ASSERT(6 == kCrashIovSize - 1, Incorrect_Number_Of_Iovec_Members);
#endif
msg.msg_iov = iov;
« no previous file with comments | « no previous file | components/breakpad/app/breakpad_linux_impl.h » ('j') | components/breakpad/browser/crash_handler_host_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698