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

New commits:
commit 372feea4bfc95454845b608d1d313a1402262203
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sat Aug 31 16:21:13 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sat Aug 31 22:08:54 2024 +0200

    cid#1607670 Overflowed constant
    
    Change-Id: I4eb19393eec6a7fb8d482597751d5fd7730213b9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172699
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 4ce56eb5af4c..3ad46e1f3768 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2185,7 +2185,8 @@ Menu* Menu::ImplFindMenu( sal_uInt16 nItemId )
 
 void Menu::RemoveDisabledEntries( bool bRemoveEmptyPopups )
 {
-    for ( sal_uInt16 n = 0; n < GetItemCount(); n++ )
+    sal_uInt16 n = 0;
+    while (n < GetItemCount())
     {
         bool bRemove = false;
         MenuItemData* pItem = pItemList->GetDataFromPos( n );
@@ -2204,8 +2205,10 @@ void Menu::RemoveDisabledEntries( bool 
bRemoveEmptyPopups )
                 bRemove = true;
         }
 
-        if ( bRemove )
-            RemoveItem( n-- );
+        if (bRemove)
+            RemoveItem(n);
+        else
+            ++n;
     }
 
     if ( GetItemCount() )

Reply via email to