diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:23:05 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:23:05 +0000 |
commit | 24f57133d4cf6da4c4122a609c6d1fd7262d6f06 (patch) | |
tree | f7f60e0d9c45638921fd33a330d29a750a373fc6 /chrome/browser | |
parent | 434ff6a6e51ac0c1853c6b0ade3af6cfea8092de (diff) | |
download | chromium_src-24f57133d4cf6da4c4122a609c6d1fd7262d6f06.zip chromium_src-24f57133d4cf6da4c4122a609c6d1fd7262d6f06.tar.gz chromium_src-24f57133d4cf6da4c4122a609c6d1fd7262d6f06.tar.bz2 |
Fix a crash in the extension system when sending response back to extension with no results. Also found an UMR causing DCHECKs to hit repeatedly (in AsyncExtensionFunction::SetArgs).
BUG=None
TEST=Basically, use any extension that calls an API function that returns no results (such as PageAction) and Chrome should not crash.
Review URL: http://codereview.chromium.org/114033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/extensions/extension_function.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_function.h | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc index f74fdb9..a846d96 100644 --- a/chrome/browser/extensions/extension_function.cc +++ b/chrome/browser/extensions/extension_function.cc @@ -10,7 +10,7 @@ #include "chrome/browser/extensions/extension_function_dispatcher.h" void AsyncExtensionFunction::SetArgs(const std::string& args) { - DCHECK(!args_); // should only be called once + DCHECK(!args_); // Should only be called once. if (!args.empty()) { JSONReader reader; args_ = reader.JsonToValue(args, false, false); @@ -26,7 +26,9 @@ void AsyncExtensionFunction::SetArgs(const std::string& args) { const std::string AsyncExtensionFunction::GetResult() { std::string json; - JSONWriter::Write(result_.get(), false, &json); + // Some functions might not need to return any results. + if (result_.get()) + JSONWriter::Write(result_.get(), false, &json); return json; } diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h index cbe85b9..5d0ddb0 100644 --- a/chrome/browser/extensions/extension_function.h +++ b/chrome/browser/extensions/extension_function.h @@ -28,6 +28,7 @@ class Profile; class ExtensionFunction { public: ExtensionFunction() : request_id_(-1), has_callback_(false) {} + virtual ~ExtensionFunction() {} // Specifies the name of the function. virtual void SetName(const std::string& name) { } @@ -79,7 +80,7 @@ class ExtensionFunction { // parsing JSON (and instead uses custom serialization of Value objects). class AsyncExtensionFunction : public ExtensionFunction { public: - AsyncExtensionFunction() : bad_message_(false) {} + AsyncExtensionFunction() : args_(NULL), bad_message_(false) {} virtual ~AsyncExtensionFunction() {} virtual void SetArgs(const std::string& args); @@ -94,7 +95,7 @@ class AsyncExtensionFunction : public ExtensionFunction { Profile* profile(); - // The arguments to the API. Only non-null if argument were specfied. + // The arguments to the API. Only non-null if argument were specified. Value* args_; // The result of the API. This should be populated by the derived class before |