From 2128669052921371684004390297e0864b8dd704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Fri, 16 Apr 2010 12:26:31 +0200 Subject: [PATCH] Fixed possible infinite loop when searching in text editor Caused by uninitialized variable and failure to check for the case where nothing is found. Done-with: mae --- src/plugins/find/basetextfind.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/find/basetextfind.cpp b/src/plugins/find/basetextfind.cpp index 72dde1ae68f..37211b5a55f 100644 --- a/src/plugins/find/basetextfind.cpp +++ b/src/plugins/find/basetextfind.cpp @@ -38,11 +38,13 @@ using namespace Find; BaseTextFind::BaseTextFind(QTextEdit *editor) : m_editor(editor), m_incrementalStartPos(-1) + , m_findScopeVerticalBlockSelection(0) { } BaseTextFind::BaseTextFind(QPlainTextEdit *editor) : m_plaineditor(editor), m_incrementalStartPos(-1) + , m_findScopeVerticalBlockSelection(0) { } @@ -280,6 +282,9 @@ bool BaseTextFind::find(const QString &txt, QTextCursor BaseTextFind::findOne(const QRegExp &expr, const QTextCursor &from, QTextDocument::FindFlags options) const { QTextCursor candidate = document()->find(expr, from, options); + if (candidate.isNull()) + return candidate; + if (!m_findScopeVerticalBlockSelection) return candidate; forever { @@ -311,7 +316,7 @@ void BaseTextFind::defineFindScope() if (cursor.hasSelection() && cursor.block() != cursor.document()->findBlock(cursor.anchor())) { m_findScopeStart = QTextCursor(document()->docHandle(), qMax(0, cursor.selectionStart()-1)); m_findScopeEnd = QTextCursor(document()->docHandle(), cursor.selectionEnd()); - m_findScopeVerticalBlockSelection = false; + m_findScopeVerticalBlockSelection = 0; int verticalBlockSelection = 0; if (m_plaineditor && m_plaineditor->metaObject()->indexOfProperty("verticalBlockSelection") >= 0)