tdf#120703 PVS: fix possible buffer over-read when iterating string
V560 A part of conditional expression is always true: nStartPos < nLen.
Change-Id: I2ae8634bd656e857724615d5187a14bd087598eb
Reviewed-on: https://gerrit.libreoffice.org/63958
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 557ca5d..9e1e115 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -167,8 +167,9 @@
sal_Int32 nRes = nStartPos;
if (0 <= nStartPos && nStartPos < nLen)
{
const sal_Unicode* const pEnd = rText.getStr() + nLen;
const sal_Unicode *pText = rText.getStr() + nStartPos;
while (nStartPos < nLen && lcl_IsWhiteSpace( *pText ))
while (pText != pEnd && lcl_IsWhiteSpace(*pText))
++pText;
nRes = pText - rText.getStr();
}