summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 00:53:08 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 00:53:08 +0000
commit4c7ca4b8c2ceb6f823474744f035672c8501d23b (patch)
tree74a0cebf409bbdbae8159026b6f0bd224cba8a5d /chrome
parentdb50c8f7779e043748ef1b958b80f15abcce880a (diff)
downloadchromium_src-4c7ca4b8c2ceb6f823474744f035672c8501d23b.zip
chromium_src-4c7ca4b8c2ceb6f823474744f035672c8501d23b.tar.gz
chromium_src-4c7ca4b8c2ceb6f823474744f035672c8501d23b.tar.bz2
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
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extensions_service.cc8
-rw-r--r--chrome/browser/extensions/extensions_service.h1
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<Value> 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<DictionaryValue*>(val);
+ DictionaryValue* manifest = static_cast<DictionaryValue*>(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<ExtensionsServiceFrontendInterface> frontend);