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

Unified Diff: tools/mac/exception_port_tool.cc

Issue 1381023007: mac: Don’t leak send rights from ExceptionPorts::GetExceptionPorts() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 2 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 | « client/simulate_crash_mac.cc ('k') | util/mach/exception_ports.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/mac/exception_port_tool.cc
diff --git a/tools/mac/exception_port_tool.cc b/tools/mac/exception_port_tool.cc
index 818ad4463b71ee0042cb5c40c4793a8a4f30d692..e26c1bb063dbb87a33b36a208bd88c750b94eacd 100644
--- a/tools/mac/exception_port_tool.cc
+++ b/tools/mac/exception_port_tool.cc
@@ -74,13 +74,20 @@ class MachSendRightPool {
//! \brief Adds a send right to the pool.
//!
//! \param[in] send_right The send right to be added. The pool object takes
- //! ownership of the send right, which remains valid until the pool object
- //! is destroyed.
+ //! its own reference to the send right, which remains valid until the
+ //! pool object is destroyed. The caller remains responsible for its
+ //! reference to the send right.
//!
//! It is possible and in fact likely that one pool will wind up owning the
//! same send right multiple times. This is acceptable, because send rights
//! are reference-counted.
void AddSendRight(mach_port_t send_right) {
+ kern_return_t kr = mach_port_mod_refs(mach_task_self(),
+ send_right,
+ MACH_PORT_RIGHT_SEND,
+ 1);
+ MACH_CHECK(kr == KERN_SUCCESS, kr) << "mach_port_mod_refs";
+
send_rights_.push_back(send_right);
}
@@ -188,9 +195,9 @@ void ShowBootstrapService(const std::string& service_name,
return;
}
- printf("service %s %#x\n", service_name.c_str(), service_port.get());
+ mach_send_right_pool->AddSendRight(service_port);
- mach_send_right_pool->AddSendRight(service_port.release());
+ printf("service %s %#x\n", service_name.c_str(), service_port.get());
}
// Prints information about all exception ports known for |exception_ports|. If
@@ -206,14 +213,14 @@ void ShowExceptionPorts(const ExceptionPorts& exception_ports,
MachSendRightPool* mach_send_right_pool) {
const char* target_name = exception_ports.TargetTypeName();
- std::vector<ExceptionPorts::ExceptionHandler> handlers;
+ ExceptionPorts::ExceptionHandlerVector handlers;
if (!exception_ports.GetExceptionPorts(ExcMaskValid(), &handlers)) {
return;
}
const char* age_name = is_new ? "new " : "";
- if (handlers.size() == 0) {
+ if (handlers.empty()) {
printf("no %s%s exception ports\n", age_name, target_name);
}
« no previous file with comments | « client/simulate_crash_mac.cc ('k') | util/mach/exception_ports.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698