summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <dangelog@gmail.com>2012-02-26 22:37:45 +0000
committerQt by Nokia <qt-info@nokia.com>2012-03-08 22:00:53 +0100
commit824cc9492144dff2494645319854cb68ba5570c6 (patch)
tree9dda541412826c98e0c8b39c7ed0671977391d56 /src/corelib
parentb5431419923e8f00e2d8a4a75a20f75f66241842 (diff)
QRegularExpression: minor fix to captureIndexForName
Although passing a null pointer to pcre16_get_stringnumber for the compiled pattern should simply make it error out, it's actually an undocumented behaviour, so let's stay safe and add an explicit check. Tests for this codepath are added. Change-Id: Ifd9c87874f6812ba487104ec1a5bbc83c3b16761 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qregularexpression.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 5deb485d3e..c7e8e6ccb8 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -1106,6 +1106,9 @@ int QRegularExpressionPrivate::captureIndexForName(const QString &name) const
{
Q_ASSERT(!name.isEmpty());
+ if (!compiledPattern)
+ return -1;
+
int index = pcre16_get_stringnumber(compiledPattern, name.utf16());
if (index >= 0)
return index;