vcl/unx/gtk4/a11y.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
New commits: commit e94a35275670e0e3775c1bba305115d9941751f1 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Sep 11 16:17:47 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Sep 12 07:08:14 2024 +0200 tdf#161256 gtk4 a11y: Don't crash on missing context or invalid child index If an `XAccessible` doesn't have a context or `XAccessibleContext::getAccessibleIndexInParent()` returns an invalid index of -1, don't crash/assert, but let `lo_accessible_get_next_accessible_sibling` return `nullptr`. This works around potential bugs in underlying `XAccessible`/`XAccessibleContext` implementations for now. This is meant to fix the assert/crash seen in the backtraces attachment 196363 and attachment 196383 from tdf#161256 which I cannot reproduce locally on Debian testing. Change-Id: Ic1779d875161469bf296c558039e19f1d426a259 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173216 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/unx/gtk4/a11y.cxx b/vcl/unx/gtk4/a11y.cxx index afa6905de553..1f864eaed960 100644 --- a/vcl/unx/gtk4/a11y.cxx +++ b/vcl/unx/gtk4/a11y.cxx @@ -763,8 +763,18 @@ static GtkAccessible* lo_accessible_get_next_accessible_sibling(GtkAccessible* s css::uno::Reference<css::accessibility::XAccessibleContext> xContext( pAccessible->uno_accessible->getAccessibleContext()); + if (!xContext.is()) + { + SAL_WARN("vcl.gtk", "Accessible has no accessible context"); + return nullptr; + } + sal_Int64 nThisChildIndex = xContext->getAccessibleIndexInParent(); - assert(nThisChildIndex != -1); + if (nThisChildIndex < 0) + { + SAL_WARN("vcl.gtk", "Invalid accessible index in parent"); + return nullptr; + } sal_Int64 nNextChildIndex = nThisChildIndex + 1; css::uno::Reference<css::accessibility::XAccessible> xParent = xContext->getAccessibleParent();