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

Side by Side Diff: tools/android/forwarder2/device_controller.cc

Issue 132053003: Android: Fix double free in DeviceController (forwarder2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "tools/android/forwarder2/device_controller.h" 5 #include "tools/android/forwarder2/device_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // TODO(felipeg): add a KillAllListeners command. 134 // TODO(felipeg): add a KillAllListeners command.
135 LOG(ERROR) << "Invalid command received. Port: " << port 135 LOG(ERROR) << "Invalid command received. Port: " << port
136 << " Command: " << command; 136 << " Command: " << command;
137 } 137 }
138 } 138 }
139 139
140 // static 140 // static
141 void DeviceController::DeleteListenerOnError( 141 void DeviceController::DeleteListenerOnError(
142 const base::WeakPtr<DeviceController>& device_controller_ptr, 142 const base::WeakPtr<DeviceController>& device_controller_ptr,
143 scoped_ptr<DeviceListener> device_listener) { 143 scoped_ptr<DeviceListener> device_listener) {
144 DeviceListener* const listener = device_listener.release();
144 DeviceController* const controller = device_controller_ptr.get(); 145 DeviceController* const controller = device_controller_ptr.get();
145 if (!controller) { 146 if (!controller) {
146 // |device_listener| was already deleted by the controller that did have 147 // |listener| was already deleted by the controller that did have its
147 // its ownership. 148 // ownership.
148 ignore_result(device_listener.release());
149 return; 149 return;
150 } 150 }
151 DCHECK(controller->construction_task_runner_->RunsTasksOnCurrentThread()); 151 DCHECK(controller->construction_task_runner_->RunsTasksOnCurrentThread());
152 bool listener_did_exist = DeleteRefCountedValueInMap( 152 bool listener_did_exist = DeleteRefCountedValueInMap(
153 device_listener->listener_port(), &controller->listeners_); 153 listener->listener_port(), &controller->listeners_);
154 DCHECK(listener_did_exist); 154 DCHECK(listener_did_exist);
155 // Note that |listener| was deleted by DeleteRefCountedValueInMap().
155 } 156 }
156 157
157 } // namespace forwarder 158 } // namespace forwarder
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