vcl/qt5/QtAccessibleWidget.cxx | 7 +++++++ 1 file changed, 7 insertions(+)
New commits: commit bc662b15bf56bd405cb86e592e4ade9917ab49d1 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jul 12 08:33:20 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 12 12:20:51 2023 +0200 qt a11y: Check child index in QtAccessibleWidget::child Check the child index is valid. Otherwise, calling the method with an invalid index would result in a crash due to a com::sun::star::lang::IndexOutOfBoundsException, e.g. when manually using an invalid index in Accerciser's IPython console: In [12]: acc.get_child_count() Out[12]: 3 In [13]: acc.get_child_at_index(3) In [14]: Change-Id: I95f680a5ac6ee1052f3046a83000fa5b07009239 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154345 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index 84b398c006cc..23dc41ce3e01 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -340,6 +340,13 @@ QAccessibleInterface* QtAccessibleWidget::child(int index) const Reference<XAccessibleContext> xAc = getAccessibleContextImpl(); if (!xAc.is()) return nullptr; + + if (index < 0 || index >= xAc->getAccessibleChildCount()) + { + SAL_WARN("vcl.qt", "QtAccessibleWidget::child called with invalid index: " << index); + return nullptr; + } + return QAccessible::queryAccessibleInterface( QtAccessibleRegistry::getQObject(xAc->getAccessibleChild(index))); }