fixed possible crash when searching backwards

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1598 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2011-01-08 15:49:06 +00:00
parent 2d646c5926
commit 89599c317b
+2 -1
View File
@@ -1195,6 +1195,7 @@ bool is_word_end(const String& s, size_t pos) {
// is find.findString() at postion pos of s
bool TextValueEditor::matchSubstr(const String& s, size_t pos, FindInfo& find) {
if (pos >= s.size()) return false;
if (find.wholeWord()) {
if (!is_word_end(s, pos - 1) || !is_word_end(s, pos + find.findString().size())) return false;
}
@@ -1236,7 +1237,7 @@ bool TextValueEditor::search(FindInfo& find, bool from_start) {
size_t start = 0;
int end = (int)(find.searchSelection() ? selection_max : selection_min) - (int)find.findString().size();
if (end < 0) return false;
for (size_t i = end ; i >= start ; --i) {
for (size_t i = end ; (int)i >= (int)start ; --i) {
if (matchSubstr(v, i, find)) return true;
}
}