diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-02 15:41:05 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-02 17:10:38 (GMT) |
commit | 7fc63dd0ff368a637dcd17e692b9d6b26278b538 (patch) | |
tree | e4535c4ebb615b52e347a97158efe40247f23a16 | |
parent | 120905fbc48ac7658fac392113bf45e00880c456 (diff) | |
download | Qt-7fc63dd0ff368a637dcd17e692b9d6b26278b538.zip Qt-7fc63dd0ff368a637dcd17e692b9d6b26278b538.tar.gz Qt-7fc63dd0ff368a637dcd17e692b9d6b26278b538.tar.bz2 |
QString::section: Fix crash with SectionIncludeLeadingSep flag
And start is out of bounds.
Reviewed-by: Thiago
Reviewed-by: Joao
Task-number: QTBUG-4306
-rw-r--r-- | src/corelib/tools/qstring.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qstring/tst_qstring.cpp | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3ef0e66..03bc053 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -3185,7 +3185,7 @@ QString QString::section(const QRegExp ®, int start, int end, SectionFlags fl if (!empty || !(flags & SectionSkipEmpty)) x++; } - if((flags & SectionIncludeLeadingSep)) { + if((flags & SectionIncludeLeadingSep) && first_i < sections.size()) { const qt_section_chunk §ion = sections.at(first_i); ret.prepend(section.string.left(section.length)); } diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index c9b3436..4ebcade 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -3503,7 +3503,10 @@ void tst_QString::section_data() << QString("\\b") << 3 << 3 << int(QString::SectionDefault) << QString("is") << true; - + QTest::newRow( "task257941-rx" ) << QString("99.0 42.3") + << QString("\\s*[AaBb]\\s*") << 1 << 1 + << int(QString::SectionIncludeLeadingSep) + << QString() << true; } void tst_QString::section() |