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

Unified Diff: chrome/browser/automation/automation_event_observers_chromeos.cc

Issue 11088032: [chromeos] Fix a use-after-free problem with LoginEventObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing heap-use-after-free problem. Created 8 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
Index: chrome/browser/automation/automation_event_observers_chromeos.cc
diff --git a/chrome/browser/automation/automation_event_observers_chromeos.cc b/chrome/browser/automation/automation_event_observers_chromeos.cc
index 6d45d0054b41f1811097ae8a71573cebf8271b6e..5db16a71d81e2321327c76b0ef9062db8c189e7e 100644
--- a/chrome/browser/automation/automation_event_observers_chromeos.cc
+++ b/chrome/browser/automation/automation_event_observers_chromeos.cc
@@ -7,14 +7,17 @@
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "content/public/browser/notification_service.h"
+using chromeos::ExistingUserController;
+
LoginEventObserver::LoginEventObserver(
AutomationEventQueue* event_queue,
- chromeos::ExistingUserController* controller,
AutomationProvider* automation)
: AutomationEventObserver(event_queue, false),
- controller_(controller),
automation_(automation->AsWeakPtr()) {
- controller_->set_login_status_consumer(this);
+ ExistingUserController* controller =
+ ExistingUserController::current_controller();
+ DCHECK(controller);
+ controller->set_login_status_consumer(this);
}
LoginEventObserver::~LoginEventObserver() {}
@@ -54,6 +57,9 @@ void LoginEventObserver::_NotifyLoginEvent(const std::string& error_string) {
if (error_string.length())
dict->SetString("error_string", error_string);
NotifyEvent(dict);
- controller_->set_login_status_consumer(NULL);
+ ExistingUserController* controller =
+ ExistingUserController::current_controller();
+ if (controller)
+ controller->set_login_status_consumer(NULL);
RemoveIfDone();
}

Powered by Google App Engine
This is Rietveld 408576698