diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 21:43:11 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 21:43:11 +0000 |
commit | 135b165d2bca7a9a7302eb4f771dc713c8100edb (patch) | |
tree | 42a9a6e7e43c89f8ae38631f44985bb70f10354d /chrome/browser/history/snippet.cc | |
parent | 05e789d0a4728cf8cd2c153443d78992c624a945 (diff) | |
download | chromium_src-135b165d2bca7a9a7302eb4f771dc713c8100edb.zip chromium_src-135b165d2bca7a9a7302eb4f771dc713c8100edb.tar.gz chromium_src-135b165d2bca7a9a7302eb4f771dc713c8100edb.tar.bz2 |
Linux: Add CHECKs to track down source of history std::string out of range exceptions.
BUG=http://crbug.com/15261
Review URL: http://codereview.chromium.org/164191
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23086 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/snippet.cc')
-rw-r--r-- | chrome/browser/history/snippet.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/chrome/browser/history/snippet.cc b/chrome/browser/history/snippet.cc index c55761d..b13a901 100644 --- a/chrome/browser/history/snippet.cc +++ b/chrome/browser/history/snippet.cc @@ -174,6 +174,8 @@ void Snippet::ExtractMatchPositions(const std::string& offsets_str, continue; const size_t start = atoi(offsets[i + 2].c_str()); const size_t end = start + atoi(offsets[i + 3].c_str()); + // Switch to DCHECK after debugging http://crbug.com/15261. + CHECK(end >= start); AddMatch(start, end, match_positions); } } @@ -224,6 +226,10 @@ void Snippet::ComputeSnippet(const MatchPositions& match_positions, const size_t match_start = match_positions[i].first; const size_t match_end = match_positions[i].second; + // Switch to DCHECK after debugging http://crbug.com/15261. + CHECK(match_end > match_start); + CHECK(match_end <= document.size()); + // Add the context, if any, to show before the match. size_t context_start = match_start; MoveByNGraphemes(bi.get(), -kSnippetContext, &context_start); @@ -231,6 +237,8 @@ void Snippet::ComputeSnippet(const MatchPositions& match_positions, if (start < match_start) { if (start > 0) snippet += kEllipsis; + // Switch to DCHECK after debugging http://crbug.com/15261. + CHECK(start < document.size()); snippet += UTF8ToWide(document.substr(start, match_start - start)); } @@ -249,11 +257,17 @@ void Snippet::ComputeSnippet(const MatchPositions& match_positions, // Yes, it's within the window. Make the end context extend just up // to the next match. end = match_positions[i + 1].first; + // Switch to DCHECK after debugging http://crbug.com/15261. + CHECK(end >= match_end); + CHECK(end <= document.size()); snippet += UTF8ToWide(document.substr(match_end, end - match_end)); } else { // No, there's either no next match or the next match is too far away. end = match_end; MoveByNGraphemes(bi.get(), kSnippetContext, &end); + // Switch to DCHECK after debugging http://crbug.com/15261. + CHECK(end >= match_end); + CHECK(end <= document.size()); snippet += UTF8ToWide(document.substr(match_end, end - match_end)); if (end < document.size()) snippet += kEllipsis; |