vcl/source/outdev/text.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit dc3b0983561f9166da9f3d48f8c64f9077193b0c
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon May 2 21:17:06 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue May 3 21:16:35 2022 +0200

    ofz: Use-of-uninitialized-value
    
    Change-Id: I9ca24a135494a49449aec63615b2d945a93e8b27
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133735
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index cdf7a360a6ca..303dcbb42177 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1095,7 +1095,7 @@ void OutputDevice::GetCaretPositions( const OUString& 
rStr, sal_Int32* pCaretXAr
     for( i = 0; i < 2 * nLen; ++i )
         if( pCaretXArray[ i ] >= 0 )
             break;
-    tools::Long nXPos = pCaretXArray[ i ];
+    tools::Long nXPos = (i < 2 * nLen) ? pCaretXArray[i] : -1;
     for( i = 0; i < 2 * nLen; ++i )
     {
         if( pCaretXArray[ i ] >= 0 )

Reply via email to