cui/source/dialogs/hltpbase.cxx |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 516f800f84b533db0082b1f39c19d1af40ab29c8
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Fri Nov 24 20:25:47 2023 +0100
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Fri Nov 24 21:31:43 2023 +0100

    tdf#158345: Opening Hyperlink dialog leads to crash
    
    terminate called after throwing an instance of 
'com::sun::star::datatransfer::UnsupportedFlavorException'
    
    relevant part of bt from this exception:
    0  0x00007f34fd6b0231 in __cxa_throw () at 
/lib/x86_64-linux-gnu/libstdc++.so.6
    1  0x00007f34e9d8207d in 
x11::X11Transferable::getTransferData(com::sun::star::datatransfer::DataFlavor 
const&) (this=0x562594fc9af0, rFlavor=...)
        at 
/home/julien/lo/libreoffice/vcl/unx/generic/dtrans/X11_transferable.cxx:58
    2  0x00007f34e9d825ec in non-virtual thunk to 
x11::X11Transferable::getTransferData(com::sun::star::datatransfer::DataFlavor 
const&) () at /home/julien/lo/libreoffice/instdir/program/libvclplug_genlo.so
    3  0x00007f34e15589f2 in SvxHyperlinkTabPageBase::Reset(SfxItemSet const&) 
(this=0x5625958378f0, rItemSet=SfxItemSet of pool 0x562591482920 with parent 
0x0 and Which ranges: [(10361, 10362)] = {...})
        at /home/julien/lo/libreoffice/cui/source/dialogs/hltpbase.cxx:468
    
    See full bt here: 
https://bugs.documentfoundation.org/attachment.cgi?id=191029
    
    Regression from:
    89d3735e05b98223a49a387421386fd736fc3de6^!
    tdf#146576 - Propose clipboard content when inserting a hyperlink
    
    Change-Id: Ic111b8348f2288c4e9e6760fe6f7f48faadec582
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159939
    Tested-by: Julien Nabet <serval2...@yahoo.fr>
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>

diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index f2448460ee66..f0aa7c368c04 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -37,6 +37,7 @@
 #include <strings.hrc>
 #include <dialmgr.hxx>
 #include <bitmaps.hlst>
+#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
 
 using namespace ::ucbhelper;
 
@@ -465,13 +466,21 @@ void SvxHyperlinkTabPageBase::Reset( const SfxItemSet& 
rItemSet)
                     if (xTransferable->isDataFlavorSupported(aFlavor))
                     {
                         OUString aClipBoardConentent;
-                        if (xTransferable->getTransferData(aFlavor) >>= 
aClipBoardConentent)
+                        try
+                        {
+                            if (xTransferable->getTransferData(aFlavor) >>= 
aClipBoardConentent)
+                            {
+                                INetURLObject aURL;
+                                aURL.SetSmartURL(aClipBoardConentent);
+                                if (!aURL.HasError())
+                                    aStrURL
+                                        = 
aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
+                            }
+                        }
+                        // tdf#158345: Opening Hyperlink dialog leads to crash
+                        // MimeType = "text/plain;charset=utf-16"
+                        catch(const 
css::datatransfer::UnsupportedFlavorException&)
                         {
-                            INetURLObject aURL;
-                            aURL.SetSmartURL(aClipBoardConentent);
-                            if (!aURL.HasError())
-                                aStrURL
-                                    = 
aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
                         }
                     }
                 }

Reply via email to