diff options
author | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-15 03:59:31 +0000 |
---|---|---|
committer | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-15 03:59:31 +0000 |
commit | 3969d2b5bf878d0d70f7790da335a6fb0995cb0d (patch) | |
tree | 8374e71a01b372cbc9f4fd91c99ecc350f1bbe8e /base/string_util.cc | |
parent | f69545fc9c65a903c533eacf467b8945ae1e8cb2 (diff) | |
download | chromium_src-3969d2b5bf878d0d70f7790da335a6fb0995cb0d.zip chromium_src-3969d2b5bf878d0d70f7790da335a6fb0995cb0d.tar.gz chromium_src-3969d2b5bf878d0d70f7790da335a6fb0995cb0d.tar.bz2 |
Linux: fix bookmarks with & in them not showing correctly in the wrench menu.
As a side effect, also fix a bug in ReplaceChars() where it would go into an
infinite loop (and probably also eventually run out of memory) if the
replacement string contained any of the characters to be replaced.
BUG=109546
Review URL: http://codereview.chromium.org/9348106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.cc')
-rw-r--r-- | base/string_util.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/base/string_util.cc b/base/string_util.cc index 22e94aa..2b9e1bc 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -170,15 +170,15 @@ bool ReplaceCharsT(const STR& input, const STR& replace_with, STR* output) { bool removed = false; - size_t found; + size_t replace_length = replace_with.length(); *output = input; - found = output->find_first_of(replace_chars); + size_t found = output->find_first_of(replace_chars); while (found != STR::npos) { removed = true; output->replace(found, 1, replace_with); - found = output->find_first_of(replace_chars, found); + found = output->find_first_of(replace_chars, found + replace_length); } return removed; |