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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 8529001: Fix crash in ExtensionService::SetIsIncognitoEnabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index bd34f2459719d93512c939efb3f673a149347912..7bf9a02fc73dc75122cff2c19cf8acae43dc3b00 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -1458,7 +1458,11 @@ bool ExtensionService::IsIncognitoEnabled(
void ExtensionService::SetIsIncognitoEnabled(
const std::string& extension_id, bool enabled) {
- const Extension* extension = GetInstalledExtension(extension_id);
+ // When we reload the extension the ID may be invalidated if we've passed it
+ // by const ref everywhere. Make a copy to be safe.
+ std::string id = extension_id;
Finnur 2011/11/11 16:01:07 nit: It would have been enough to make the copy ri
jstritar 2011/11/11 16:31:37 Done.
+
+ const Extension* extension = GetInstalledExtension(id);
if (extension && extension->location() == Extension::COMPONENT) {
// This shouldn't be called for component extensions.
NOTREACHED();
@@ -1468,19 +1472,19 @@ void ExtensionService::SetIsIncognitoEnabled(
// Broadcast unloaded and loaded events to update browser state. Only bother
// if the value changed and the extension is actually enabled, since there is
// no UI otherwise.
- bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id);
+ bool old_enabled = extension_prefs_->IsIncognitoEnabled(id);
if (enabled == old_enabled)
return;
- extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled);
+ extension_prefs_->SetIsIncognitoEnabled(id, enabled);
bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(),
extension) != extensions_.end();
if (extension_is_enabled)
- ReloadExtension(extension->id());
+ ReloadExtension(id);
// Reloading the extension invalidates the |extension| pointer.
- extension = GetInstalledExtension(extension_id);
+ extension = GetInstalledExtension(id);
if (extension)
SyncExtensionChangeIfNeeded(*extension);
}
« 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