From 481930be315663b2f3db2de3d22c45f803af9e8f Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 26 Feb 2020 12:45:49 +0100 Subject: qdoc: Fix warning when accessing a QString outside of its range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Topi Reiniƶ --- src/qdoc/doc.cpp | 4 ++-- 1 file 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))); } } -- cgit v1.2.3