From 4c7ca4b8c2ceb6f823474744f035672c8501d23b Mon Sep 17 00:00:00 2001 From: "erikkay@google.com" Date: Wed, 4 Feb 2009 00:53:08 +0000 Subject: Fix a leak in the extension installation code. Review URL: http://codereview.chromium.org/21027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9113 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/extensions/extensions_service.cc | 8 +++++--- chrome/browser/extensions/extensions_service.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index d749fd57..c591257 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -311,8 +311,8 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest( // Verify the JSON JSONStringValueSerializer json(manifest_str); std::string error; - Value* val = json.Deserialize(&error); - if (!val) { + scoped_ptr val(json.Deserialize(&error)); + if (!val.get()) { ReportExtensionInstallError(frontend, extension_path, error); return NULL; } @@ -321,7 +321,7 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest( "manifest isn't a JSON dictionary"); return NULL; } - DictionaryValue* manifest = static_cast(val); + DictionaryValue* manifest = static_cast(val.get()); std::string zip_hash; if (!manifest->GetString(Extension::kZipHashKey, &zip_hash)) { ReportExtensionInstallError(frontend, extension_path, @@ -367,6 +367,8 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest( // TODO(erikkay): The manifest will also contain a signature of the hash // (or perhaps the whole manifest) for authentication purposes. + // The caller owns val (now cast to manifest). + val.release(); return manifest; } diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h index 0421f4b..8382786 100644 --- a/chrome/browser/extensions/extensions_service.h +++ b/chrome/browser/extensions/extensions_service.h @@ -160,6 +160,7 @@ class ExtensionsServiceBackend FilePath path); // Read the manifest from the front of the extension file. + // Caller takes ownership of return value. DictionaryValue* ReadManifest(const FilePath& extension_path, scoped_refptr frontend); -- cgit v1.1