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

Unified Diff: mojo/public/cpp/system/core.h

Issue 336313003: mojo: Don't leak handles when assigning to ScopedHandles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | « no previous file | mojo/public/cpp/system/tests/core_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/system/core.h
diff --git a/mojo/public/cpp/system/core.h b/mojo/public/cpp/system/core.h
index 2b1caa914a4b69770a9e632dbad6e01564bb5229..b7d0456bdc04ca7f23958351f54199003b7aac59 100644
--- a/mojo/public/cpp/system/core.h
+++ b/mojo/public/cpp/system/core.h
@@ -107,6 +107,8 @@ class ScopedHandleBase {
// Move-only constructor and operator=.
ScopedHandleBase(RValue other) : handle_(other.object->release()) {}
ScopedHandleBase& operator=(RValue other) {
+ if (handle_.is_valid() && handle_.value() != other.object->get().value())
viettrungluu 2014/06/17 22:58:25 Since a handle should only be in a single ScopedHa
Elliot Glaysher 2014/06/17 23:08:28 Switched to if (other.object != this). Didn't add
+ CloseIfNecessary();
handle_ = other.object->release();
return *this;
}
« no previous file with comments | « no previous file | mojo/public/cpp/system/tests/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698