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

Side by Side Diff: bookmarks/bookmark_codec.cc

Issue 342046: Fix for crash when a bookmark URL is an empty string ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/chrome/browser/
Patch Set: Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | bookmarks/bookmark_storage.cc » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/bookmarks/bookmark_codec.h" 5 #include "chrome/browser/bookmarks/bookmark_codec.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return false; 230 return false;
231 231
232 if (type_string != kTypeURL && type_string != kTypeFolder) 232 if (type_string != kTypeURL && type_string != kTypeFolder)
233 return false; // Unknown type. 233 return false; // Unknown type.
234 234
235 if (type_string == kTypeURL) { 235 if (type_string == kTypeURL) {
236 std::wstring url_string; 236 std::wstring url_string;
237 if (!value.GetString(kURLKey, &url_string)) 237 if (!value.GetString(kURLKey, &url_string))
238 return false; 238 return false;
239 239
240 if (!node) 240 GURL url = GURL(WideToUTF8(url_string));
241 node = new BookmarkNode(id, GURL(WideToUTF8(url_string))); 241 if (!node && url.is_valid())
242 node = new BookmarkNode(id, url);
242 else 243 else
243 return false; // Node invalid. 244 return false; // Node invalid.
244 245
245 if (parent) 246 if (parent)
246 parent->Add(parent->GetChildCount(), node); 247 parent->Add(parent->GetChildCount(), node);
247 node->set_type(BookmarkNode::URL); 248 node->set_type(BookmarkNode::URL);
248 UpdateChecksumWithUrlNode(id_string, title, url_string); 249 UpdateChecksumWithUrlNode(id_string, title, url_string);
249 } else { 250 } else {
250 std::wstring last_modified_date; 251 std::wstring last_modified_date;
251 if (!value.GetString(kDateModifiedKey, &last_modified_date)) 252 if (!value.GetString(kDateModifiedKey, &last_modified_date))
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 325
325 void BookmarkCodec::InitializeChecksum() { 326 void BookmarkCodec::InitializeChecksum() {
326 MD5Init(&md5_context_); 327 MD5Init(&md5_context_);
327 } 328 }
328 329
329 void BookmarkCodec::FinalizeChecksum() { 330 void BookmarkCodec::FinalizeChecksum() {
330 MD5Digest digest; 331 MD5Digest digest;
331 MD5Final(&digest, &md5_context_); 332 MD5Final(&digest, &md5_context_);
332 computed_checksum_ = MD5DigestToBase16(digest); 333 computed_checksum_ = MD5DigestToBase16(digest);
333 } 334 }
OLDNEW
« no previous file with comments | « no previous file | bookmarks/bookmark_storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698