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

Unified Diff: remoting/webapp/host_controller.js

Issue 10221021: Protect all uses of JSON.parse against exceptions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments. Created 8 years, 8 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 | « remoting/webapp/client_screen.js ('k') | remoting/webapp/host_list.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/host_controller.js
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js
index 80870ac79f495f60c033fe08ff3ff3b28876e026..750212ed97f96147bb08e124fe3a2ebe48431ed2 100644
--- a/remoting/webapp/host_controller.js
+++ b/remoting/webapp/host_controller.js
@@ -244,13 +244,13 @@ remoting.HostController.prototype.stop = function(callback) {
* @return {Object.<string,string>|null} The host configuration.
*/
function parseHostConfig_(configStr) {
- try {
- var config = /** @type {Object.<string,string>} */ JSON.parse(configStr);
- if (typeof config['host_id'] == 'string' &&
- typeof config['xmpp_login'] == 'string') {
- return config;
- }
- } catch (err) {
+ var config = /** @type {Object.<string,string>} */ jsonParseSafe(configStr);
+ if (config &&
+ typeof config['host_id'] == 'string' &&
+ typeof config['xmpp_login'] == 'string') {
+ return config;
+ } else {
+ console.error('Invalid getDaemonConfig response.');
}
return null;
}
« no previous file with comments | « remoting/webapp/client_screen.js ('k') | remoting/webapp/host_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698