summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenugopal Shivashankar <Venugopal.Shivashankar@qt.io>2022-03-15 15:21:30 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-16 15:28:50 +0000
commit51a0a407a2c8b85ad1e49b822c764e91f96008a7 (patch)
treeb716ced4530125e6be92ed773aff5543c78dcd13
parentc12a3030f68d8b2ef7f725471d19e86ef76c9f48 (diff)
qhelpgenerator: Fix infinite loop issue in checkLinks
The while loop that looks for the next match, depends on the offset to move to the next match. Even before this offset is updated, the loop is continued if the first capture group of the `linkPattern` regex contains the sequence "://", making the loop to iterate over the same match. Getting all the matches at once and iterating over them is probably a better alternative. Amends 85803440b28aadd3f4fe3e99a52e52378671b9e0 Fixes: QTBUG-101070 Change-Id: I0acd4428244398ccfbb88e042229a928c234b951 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io> (cherry picked from commit 99ba60bad93c78398c47e39b35b07b4074ca2c42) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/assistant/qhelpgenerator/helpgenerator.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/assistant/qhelpgenerator/helpgenerator.cpp b/src/assistant/qhelpgenerator/helpgenerator.cpp
index 47a11163f..6407bbbf0 100644
--- a/src/assistant/qhelpgenerator/helpgenerator.cpp
+++ b/src/assistant/qhelpgenerator/helpgenerator.cpp
@@ -817,6 +817,7 @@ bool HelpGeneratorPrivate::checkLinks(const QHelpProjectData &helpData)
QRegularExpressionMatch match;
int pos = 0;
while ((match = linkPattern.match(content, pos)).hasMatch()) {
+ pos = match.capturedEnd();
const QString &linkedFileName = match.captured(1);
if (linkedFileName.contains(QLatin1String("://")))
continue;
@@ -830,7 +831,6 @@ bool HelpGeneratorPrivate::checkLinks(const QHelpProjectData &helpData)
allLinksOk = false;
invalidLinks.append(canonicalLinkedFileName);
}
- pos = match.capturedEnd();
}
}