From 89599c317b32115777e5af68401f37b23905338c Mon Sep 17 00:00:00 2001 From: twanvl Date: Sat, 8 Jan 2011 15:49:06 +0000 Subject: [PATCH] fixed possible crash when searching backwards git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1598 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/value/text.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/value/text.cpp b/src/gui/value/text.cpp index b8f5b538..794bc6d5 100644 --- a/src/gui/value/text.cpp +++ b/src/gui/value/text.cpp @@ -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; } }