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

Unified Diff: google/bdict_reader.cc

Issue 257004: Speculative fix for Hunspell crash in bug 14721. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/hunspell128/
Patch Set: '' Created 11 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google/bdict_reader.cc
===================================================================
--- google/bdict_reader.cc (revision 26238)
+++ google/bdict_reader.cc (working copy)
@@ -338,8 +338,10 @@
}
// Range check the offset;
- if (child_offset > bdict_length_)
+ if (child_offset >= bdict_length_) {
+ DCHECK(false) << "Offset should be less than length.";
return FIND_DONE;
+ }
// Now recurse into that child node. We don't advance to the next character
// here since the 0th element will be a leaf (see ReaderForLookupAt).
@@ -373,8 +375,10 @@
}
// Range check the offset;
- if (child_offset > bdict_length_)
+ if (child_offset >= bdict_length_) {
+ DCHECK(false) << "Offset should be less than length.";
return FIND_DONE; // Error.
+ }
// This is a bit tricky. When we've just reached the end of a word, the word
// itself will be stored in a leaf "node" off of this node. That node, of
@@ -447,8 +451,10 @@
offset = children_begin + list_item_begin[1];
}
- if (offset == 0 || node_offset_ > bdict_length_)
+ if (offset == 0 || node_offset_ >= bdict_length_) {
+ DCHECK(false) << "Offset should be less than length.";
return FIND_DONE; // Error, should not happen except for corruption.
+ }
int char_advance = *found_char == 0 ? 0 : 1; // See ReaderForLookupAt.
*result = NodeReader(bdict_data_, bdict_length_,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698