vcl/source/window/menu.cxx |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit e1ecdda0c13fbf4ae145eebd7a366ea109a56a66
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Nov 1 09:15:14 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sun Nov 17 17:40:21 2024 +0100

    cid#1607974 silence Overflowed return value
    
    Change-Id: I9663f3e0cb641bd4530e1aca06d4216de74e38cd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176691
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 5a07e45e3064..9b00d9cb23bf 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2275,26 +2275,25 @@ tools::Rectangle Menu::GetCharacterBounds( sal_uInt16 
nItemID, tools::Long nInde
 
 tools::Long Menu::GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) 
const
 {
-    tools::Long nIndex = -1;
     rItemID = 0;
     if( ! mpLayoutData )
         ImplFillLayoutData();
     if( mpLayoutData )
     {
-        nIndex = mpLayoutData->GetIndexForPoint( rPoint );
+        // coverity[ tainted_data_return : FALSE ] version 2023.12.2
+        tools::Long nIndex = mpLayoutData->GetIndexForPoint( rPoint );
         for( size_t i = 0; i < mpLayoutData->m_aLineIndices.size(); i++ )
         {
             if( mpLayoutData->m_aLineIndices[i] <= nIndex &&
                 (i == mpLayoutData->m_aLineIndices.size()-1 || 
mpLayoutData->m_aLineIndices[i+1] > nIndex) )
             {
-                // make index relative to item
-                nIndex -= mpLayoutData->m_aLineIndices[i];
                 rItemID = mpLayoutData->m_aLineItemIds[i];
-                break;
+                // return index relative to item
+                return nIndex - mpLayoutData->m_aLineIndices[i];
             }
         }
     }
-    return nIndex;
+    return -1;
 }
 
 tools::Rectangle Menu::GetBoundingRectangle( sal_uInt16 nPos ) const

Reply via email to