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

Side by Side Diff: mojo/public/cpp/bindings/remote_ptr.h

Issue 269893003: Fix leak in RemotePtr::operator=(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_
7 7
8 #include <assert.h> 8 #include <assert.h>
9 9
10 #include "mojo/public/cpp/bindings/interface.h" 10 #include "mojo/public/cpp/bindings/interface.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 typename S::_Peer* peer, 79 typename S::_Peer* peer,
80 ErrorHandler* error_handler = NULL, 80 ErrorHandler* error_handler = NULL,
81 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) 81 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter())
82 : state_(new State(ScopedMessagePipeHandle(interface_handle.Pass()), peer, 82 : state_(new State(ScopedMessagePipeHandle(interface_handle.Pass()), peer,
83 error_handler, waiter)) { 83 error_handler, waiter)) {
84 } 84 }
85 85
86 // Move-only constructor and operator=. 86 // Move-only constructor and operator=.
87 RemotePtr(RValue other) : state_(other.object->release()) {} 87 RemotePtr(RValue other) : state_(other.object->release()) {}
88 RemotePtr& operator=(RValue other) { 88 RemotePtr& operator=(RValue other) {
89 delete state_;
89 state_ = other.object->release(); 90 state_ = other.object->release();
90 return *this; 91 return *this;
91 } 92 }
92 93
93 ~RemotePtr() { 94 ~RemotePtr() {
94 delete state_; 95 delete state_;
95 } 96 }
96 97
97 bool is_null() const { 98 bool is_null() const {
98 return !state_; 99 return !state_;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 state_ = NULL; 148 state_ = NULL;
148 return state; 149 return state;
149 } 150 }
150 151
151 State* state_; 152 State* state_;
152 }; 153 };
153 154
154 } // namespace mojo 155 } // namespace mojo
155 156
156 #endif // MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_ 157 #endif // MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698