summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-02-26 12:45:49 +0100
committerAndy Shaw <andy.shaw@qt.io>2020-02-26 22:26:07 +0100
commit481930be315663b2f3db2de3d22c45f803af9e8f (patch)
treeeefa587aa62d8605e062a5c42478f57711153b2f
parent0fa60787e42e4474427d95001c13224d554dcb62 (diff)
qdoc: Fix warning when accessing a QString outside of its range
Since skipSpacesOnLine() can end up making pos == len then we need to check pos is less than length before querying input_ with that position. This fixes the warning "Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt." Fixes: QTBUG-80346 Change-Id: Ica1c57f616c3efaefd597ebb84e52b17325d22fa Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r--src/qdoc/doc.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp
index d6dc2871e..eb5b5036f 100644
--- a/src/qdoc/doc.cpp
+++ b/src/qdoc/doc.cpp
@@ -1814,7 +1814,7 @@ void DocParser::parseAlso()
if (input_[pos] == '{') {
target = getArgument();
skipSpacesOnLine();
- if (input_[pos] == '{') {
+ if (pos < len && input_[pos] == '{') {
str = getArgument();
// hack for C++ to support links like \l{QString::}{count()}
@@ -1841,7 +1841,7 @@ void DocParser::parseAlso()
if (pos < len && input_[pos] == ',') {
pos++;
skipSpacesOrOneEndl();
- } else if (input_[pos] != '\n') {
+ } else if (pos >= len || input_[pos] != '\n') {
location().warning(tr("Missing comma in '\\%1'").arg(cmdName(CMD_SA)));
}
}