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

Unified Diff: chrome/browser/bookmarks/bookmark_codec.cc

Issue 159075: Fixing potential memory leak in BookmarkCodec::DecodeNode.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 | « chrome/browser/bookmarks/bookmark_codec.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/bookmarks/bookmark_codec.cc
===================================================================
--- chrome/browser/bookmarks/bookmark_codec.cc (revision 21378)
+++ chrome/browser/bookmarks/bookmark_codec.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -180,6 +180,13 @@
bool BookmarkCodec::DecodeNode(const DictionaryValue& value,
BookmarkNode* parent,
BookmarkNode* node) {
+ // If no |node| is specified, we'll create one and add it to the |parent|.
+ // Therefore, in that case, |parent| must be non-NULL.
+ if (!node && !parent) {
+ NOTREACHED();
+ return false;
+ }
+
std::string id_string;
int64 id = 0;
if (!value.GetString(kIdKey, &id_string) || !StringToInt64(id_string, &id))
@@ -209,7 +216,7 @@
if (!node)
node = new BookmarkNode(id, GURL(WideToUTF8(url_string)));
else
- return false; // Node invalid.
+ return false; // Node invalid.
if (parent)
parent->Add(parent->GetChildCount(), node);
« no previous file with comments | « chrome/browser/bookmarks/bookmark_codec.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698