summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-07-12 08:33:20 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2023-07-12 12:20:51 +0200
commitbc662b15bf56bd405cb86e592e4ade9917ab49d1 (patch)
tree07d8078fd7f18adcc8f136d75863ef8e8633e750 /vcl
parenta5efa490b09f966e3d863ab948fc1608ba863899 (diff)
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.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/QtAccessibleWidget.cxx7
1 files changed, 7 insertions, 0 deletions
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)));
}