vcl/osx/salframeview.mm | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)
New commits: commit e9c4c10769be076b300aed341136254cc523a940 Author: Patrick Luby <[email protected]> AuthorDate: Mon Sep 29 21:06:50 2025 -0400 Commit: Ilmari Lauhakangas <[email protected]> CommitDate: Wed Oct 1 12:44:18 2025 +0200 tdf#168609 catch exceptions from SwXText::getString() Apparently, implementions of XTextRange::getString() such as SwXText::getString() can throw an exception. Change-Id: Ie23651bbc36466ec95a037142f760dd59c7d6417 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191645 Reviewed-by: Noel Grandin <[email protected]> Reviewed-by: Patrick Luby <[email protected]> Tested-by: Jenkins (cherry picked from commit b86c16870251877962e986ec9d1418e1f376241f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191696 Reviewed-by: Ilmari Lauhakangas <[email protected]> Tested-by: Ilmari Lauhakangas <[email protected]> diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index 1ee463f31a51..c05bd28d5413 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -22,6 +22,7 @@ #include <memory> #include <basegfx/numeric/ftools.hxx> +#include <comphelper/diagnose_ex.hxx> #include <officecfg/Office/Common.hxx> #include <sal/macros.h> #include <tools/helpers.hxx> @@ -363,7 +364,21 @@ static NSString* getCurrentSelection() { css::uno::Reference<css::text::XTextRange> xTextRange(xIndexAccess->getByIndex(0), css::uno::UNO_QUERY); if (xTextRange.is()) - return [CreateNSString(xTextRange->getString()) autorelease]; + { + // tdf#168609 catch exceptions from SwXText::getString() + // Apparently, implementions of XTextRange::getString() + // such as SwXText::getString() can throw an exception. + OUString aStr; + try + { + aStr = xTextRange->getString(); + } + catch (css::uno::RuntimeException &) + { + TOOLS_WARN_EXCEPTION("vcl.osx", "getCurrentSelection: XTextRange::getString() threw RuntimeException"); + } + return [CreateNSString(aStr) autorelease]; + } } } @@ -382,7 +397,21 @@ static NSString* getCurrentSelection() // and Impress css::uno::Reference<css::text::XTextRange> xTextRange(xSelection, css::uno::UNO_QUERY); if (xTextRange.is()) - return [CreateNSString(xTextRange->getString()) autorelease]; + { + // tdf#168609 catch exceptions from SwXText::getString() + // Apparently, implementions of XTextRange::getString() + // such as SwXText::getString() can throw an exception. + OUString aStr; + try + { + aStr = xTextRange->getString(); + } + catch (css::uno::RuntimeException &) + { + TOOLS_WARN_EXCEPTION("vcl.osx", "getCurrentSelection: XTextRange::getString() threw RuntimeException"); + } + return [CreateNSString(aStr) autorelease]; + } } } }
