diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2012-05-18 15:17:25 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-19 01:45:04 +0200 |
commit | 281771ee201e591d4f40a161b93c71914b1b38f2 (patch) | |
tree | f5236138139b45cf6ee2c81dac7b0cb425472e70 | |
parent | 7968543bb0308395226a8847274dc3b836dd7b87 (diff) |
QRegExp: fix usage of uninitialized values
A (probable) typo was causing the code dealing with anchors
to use uninitialized values. This used to work by chance, but was
indeed detected by Valgrind f.i. when running tst_qregexp --
the indexIn test on anc11 data reported:
==3015== Conditional jump or move depends on uninitialised value(s)
==3015== at 0x514B4EA: PeppeQt::QRegExpMatchState::testAnchor(int, int, int const*) (qregexp.cpp:1813)
[...]
==3015== Uninitialised value was created by a stack allocation
==3015== at 0x514B3EB: PeppeQt::QRegExpMatchState::testAnchor(int, int, int const*) (qregexp.cpp:1803)
Fixing the code also makes the aforementioned test to succeed.
Change-Id: If7b3e518c1bbfcf12573d2637c33ef2eca27c4d5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
-rw-r--r-- | src/corelib/tools/qregexp.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qregexp/tst_qregexp.cpp | 2 |
2 files changed, 1 insertions, 3 deletions
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index 79ceba5ceb..792b9cee4a 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -1839,7 +1839,7 @@ bool QRegExpMatchState::testAnchor(int i, int a, const int *capBegin) QRegExpMatchState matchState; matchState.prepareForMatch(ahead[j]->eng); matchState.match(in + pos + i, len - pos - i, 0, - true, true, matchState.caretPos - matchState.pos - i); + true, true, caretPos - pos - i); if ((matchState.captured[0] == 0) == ahead[j]->neg) return false; } diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index 4e1fba5fcb..b1ef096195 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -571,7 +571,6 @@ void tst_QRegExp::indexIn() int mylen = rx.matchedLength(); QStringList mycaps = rx.capturedTexts(); - QEXPECT_FAIL("anc11", "QRegExp has bugs with anchors inside lookaheads", Abort); QCOMPARE( mypos, pos ); QCOMPARE( mylen, len ); if ( caps.size() > 1 && caps[1] != "IGNORE ME" ) { @@ -625,7 +624,6 @@ void tst_QRegExp::lastIndexIn() QStringList mycaps = rx.capturedTexts(); if ( mypos <= pos || pos == -1 ) { - QEXPECT_FAIL("anc11", "QRegExp has bugs with anchors inside lookaheads", Abort); QCOMPARE( mypos, pos ); QCOMPARE( mylen, len ); |