From d82349e3fcc87b7a9f52a009b14c5e3336a39700 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 24 Nov 2018 22:01:16 +0300 Subject: 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 --- linguistic/source/gciterator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'linguistic') diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 557ca5d62c06..9e1e11532080 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -167,8 +167,9 @@ static sal_Int32 lcl_SkipWhiteSpaces( const OUString &rText, sal_Int32 nStartPos 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(); } -- cgit