framework/source/uielement/menubarmanager.cxx |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 5d996d2bcfcd16affffe411c68be070967f4feae
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Wed Mar 20 21:42:50 2024 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Wed May 8 16:42:38 2024 +0200

    framework: MenuBarManager: fix WNT crash if queryDispatch() throws
    
    a Java extension throws RuntimeException from queryDispatch(), which is
    translated to a C++ exception and thrown by the mscx_uno bridge, and this
    is apparently not handled anywhere (Visual Studio says "Unhandled
    Exception"), and what happens then apparently is the exception goes poof
    and vanishes, and normal return from the mscx_uno bridge code happens,
    but the out parameter used for the return value is never initialised, and
    then the uno::Reference move assignment operator crashes.
    
    Change-Id: I21535fcf0ab4ec30a712d01b5039b7e2fb7b09d7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165081
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 447a15f4772bcbc9366cfa43b92c55ae644e9b03)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165113
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Tested-by: Jenkins

diff --git a/framework/source/uielement/menubarmanager.cxx 
b/framework/source/uielement/menubarmanager.cxx
index 2abd58434827..fd9485a01909 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -660,7 +660,16 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool )
                 if ( aTargetURL.Complete.startsWith( ".uno:StyleApply?" ) )
                     xMenuItemDispatch = new StyleDispatcher( m_xFrame, 
m_xURLTransformer, aTargetURL );
                 else
-                    xMenuItemDispatch = xDispatchProvider->queryDispatch( 
aTargetURL, menuItemHandler->aTargetFrame, 0 );
+                {
+                    try
+                    {
+                        xMenuItemDispatch = xDispatchProvider->queryDispatch( 
aTargetURL, menuItemHandler->aTargetFrame, 0 );
+                    }
+                    catch (uno::Exception const&)
+                    {
+                        TOOLS_WARN_EXCEPTION("fwk.uielement", 
"MenuBarManager::Activate(): exception from queryDispatch()");
+                    }
+                }
 
                 bool bPopupMenu( false );
                 if ( !menuItemHandler->xPopupMenuController.is() &&

Reply via email to