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

Unified Diff: base/json/json_value_converter.h

Issue 9113075: Fix a potential memory leak bug. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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 | « no previous file | base/json/json_value_converter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_value_converter.h
diff --git a/base/json/json_value_converter.h b/base/json/json_value_converter.h
index 0bb131cba39ee6ba95db4be48d5c73eb1d33935f..6fbe2467a6b6294dca493bba04de3755a4d7a913 100644
--- a/base/json/json_value_converter.h
+++ b/base/json/json_value_converter.h
@@ -259,9 +259,9 @@ class RepeatedValueConverter : public ValueConverter<ScopedVector<Element> > {
if (!list->Get(i, &element))
continue;
- Element *e = new Element;
- if (basic_converter_.Convert(*element, e)) {
- field->push_back(e);
+ scoped_ptr<Element> e(new Element);
+ if (basic_converter_.Convert(*element, e.get())) {
+ field->push_back(e.release());
} else {
DVLOG(1) << "failure at " << i << "-th element";
return false;
@@ -293,9 +293,9 @@ class RepeatedMessageConverter
if (!list->Get(i, &element))
continue;
- NestedType* nested = new NestedType();
- if (converter_.Convert(*element, nested)) {
- field->push_back(nested);
+ scoped_ptr<NestedType> nested(new NestedType);
+ if (converter_.Convert(*element, nested.get())) {
+ field->push_back(nested.release());
} else {
DVLOG(1) << "failure at " << i << "-th element";
return false;
« no previous file with comments | « no previous file | base/json/json_value_converter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698