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

Unified Diff: chrome/browser/ui/webui/help/version_updater_win.cc

Issue 15649007: Attempt to fix use-after-free in VersionUpdaterWin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: one more spot Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/help/version_updater_win.cc
diff --git a/chrome/browser/ui/webui/help/version_updater_win.cc b/chrome/browser/ui/webui/help/version_updater_win.cc
index 2df0593bea11fcccea45945b581d95b808f34031..5cfa86faa75a08d5962fbca0ddeb1c47856aa987 100644
--- a/chrome/browser/ui/webui/help/version_updater_win.cc
+++ b/chrome/browser/ui/webui/help/version_updater_win.cc
@@ -62,6 +62,9 @@ class VersionUpdaterWin : public VersionUpdater,
// Little helper function to reset google_updater_.
void SetGoogleUpdater();
+ // Helper function to clear google_updater_.
+ void ClearGoogleUpdater();
+
// Returns a window that can be used for elevation.
HWND GetElevationParent();
@@ -127,8 +130,7 @@ VersionUpdaterWin::VersionUpdaterWin()
VersionUpdaterWin::~VersionUpdaterWin() {
// The Google Updater will hold a pointer to the listener until it reports
// status, so that pointer must be cleared when the listener is destoyed.
- if (google_updater_)
- google_updater_->set_status_listener(NULL);
+ ClearGoogleUpdater();
}
void VersionUpdaterWin::CheckForUpdate(const StatusCallback& callback) {
@@ -159,7 +161,7 @@ void VersionUpdaterWin::OnReportResults(
GoogleUpdateUpgradeResult result, GoogleUpdateErrorCode error_code,
const string16& error_message, const string16& version) {
// Drop the last reference to the object so that it gets cleaned up here.
- google_updater_ = NULL;
+ ClearGoogleUpdater();
UpdateStatus(result, error_code, error_message);
}
@@ -257,10 +259,18 @@ void VersionUpdaterWin::GotInstalledVersion(const Version& version) {
}
void VersionUpdaterWin::SetGoogleUpdater() {
MAD 2013/05/28 19:37:06 While you are there, maybe we should rename this t
grt (UTC plus 2) 2013/05/28 19:49:09 Nice idea. I went for "CreateGoogleUpdater". SGTY?
+ ClearGoogleUpdater();
google_updater_ = new GoogleUpdate();
google_updater_->set_status_listener(this);
}
+void VersionUpdaterWin::ClearGoogleUpdater() {
+ if (google_updater_) {
+ google_updater_->set_status_listener(NULL);
+ google_updater_ = NULL;
+ }
+}
+
BOOL CALLBACK WindowEnumeration(HWND window, LPARAM param) {
if (IsWindowVisible(window)) {
HWND* returned_window = reinterpret_cast<HWND*>(param);
« 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