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

Side by Side Diff: chrome/browser/devtools/devtools_protocol.cc

Issue 305013006: Fix memory leak in DevToolsProtocol::ParseCommand (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/devtools/devtools_protocol.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/devtools/devtools_protocol.h" 5 #include "chrome/browser/devtools/devtools_protocol.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 10
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 int id; 122 int id;
123 if (!command_dict->GetInteger(kIdParam, &id) || id < 0) 123 if (!command_dict->GetInteger(kIdParam, &id) || id < 0)
124 return NULL; 124 return NULL;
125 125
126 std::string method; 126 std::string method;
127 if (!command_dict->GetString(kMethodParam, &method)) 127 if (!command_dict->GetString(kMethodParam, &method))
128 return NULL; 128 return NULL;
129 129
130 base::DictionaryValue* params = NULL; 130 base::DictionaryValue* params = NULL;
131 command_dict->GetDictionary(kParamsParam, &params); 131 command_dict->GetDictionary(kParamsParam, &params);
132 return new Command(id, method, params ? params->DeepCopy() : NULL); 132 return new Command(id, method, params);
133 } 133 }
134 134
135 // static 135 // static
136 DevToolsProtocol::Notification* DevToolsProtocol::ParseNotification( 136 DevToolsProtocol::Notification* DevToolsProtocol::ParseNotification(
137 const std::string& json) { 137 const std::string& json) {
138 scoped_ptr<base::Value> value(base::JSONReader::Read(json)); 138 scoped_ptr<base::Value> value(base::JSONReader::Read(json));
139 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) 139 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY))
140 return NULL; 140 return NULL;
141 141
142 scoped_ptr<base::DictionaryValue> dict( 142 scoped_ptr<base::DictionaryValue> dict(
(...skipping 20 matching lines...) Expand all
163 int id; 163 int id;
164 if (!dict->GetInteger(kIdParam, &id)) 164 if (!dict->GetInteger(kIdParam, &id))
165 return NULL; 165 return NULL;
166 166
167 int error_code = 0; 167 int error_code = 0;
168 base::DictionaryValue* error_dict = NULL; 168 base::DictionaryValue* error_dict = NULL;
169 if (dict->GetDictionary(kErrorParam, &error_dict)) 169 if (dict->GetDictionary(kErrorParam, &error_dict))
170 error_dict->GetInteger(kErrorCodeParam, &error_code); 170 error_dict->GetInteger(kErrorCodeParam, &error_code);
171 return new Response(id, error_code, std::string()); 171 return new Response(id, error_code, std::string());
172 } 172 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_protocol.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698