summaryrefslogtreecommitdiff
path: root/vcl/osx/a11yrolehelper.mm
diff options
context:
space:
mode:
authorPatrick Luby <plubius@neooffice.org>2023-06-15 17:10:17 -0400
committerPatrick Luby <plubius@neooffice.org>2023-06-16 18:38:55 +0200
commitb6299c9e56f70ebc124814f4001e149e7be298ad (patch)
tree5d454a42e4e839e46009287bd060476162c0b40b /vcl/osx/a11yrolehelper.mm
parent52c34f4e84c5125e2a3c72b57a3c4d30a593debd (diff)
tdf#146626 catch IndexOutOfBoundsException when fetching accessible children
com::sun::star::accessibility::XAccessibleContext::getAccessibleChild() can throw an IndexOutOfBoundsException exception even when fetching with an index that is positive and less than the value returned by a call to the accessible context's getAccessibleChildCount() method so put every getAccessibleChild() call in a try/catch block. Note: this is actually expected behavior even though it is rare. For example, accessibility::AccessibleTextHelper_Impl::getAccessibleChild() uses the following code snippet to throw such an exception: if( 0 > i || i >= getAccessibleChildCount() || GetTextForwarder().GetParagraphCount() <= i ) In the case of tdf#146626, getAccessibleChildCount() returns 22 but getAccessibleChild(1) throws such an exception due to the last condition in the above code snippet. Change-Id: If974afb7b9178faa99b91dcd79eb5f169bbfe13e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153160 Tested-by: Jenkins Reviewed-by: Patrick Luby <plubius@neooffice.org>
Diffstat (limited to 'vcl/osx/a11yrolehelper.mm')
-rw-r--r--vcl/osx/a11yrolehelper.mm26
1 files changed, 18 insertions, 8 deletions
diff --git a/vcl/osx/a11yrolehelper.mm b/vcl/osx/a11yrolehelper.mm
index 5cb75c94a86f..e95036dbebd9 100644
--- a/vcl/osx/a11yrolehelper.mm
+++ b/vcl/osx/a11yrolehelper.mm
@@ -24,8 +24,12 @@
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+
+#include <sal/log.hxx>
using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
@implementation AquaA11yRoleHelper
@@ -153,17 +157,23 @@ using namespace ::com::sun::star::uno;
}
}
} else if ( accessibleContext -> getAccessibleRole() == AccessibleRole::COMBO_BOX ) {
- Reference < XAccessible > rxAccessible = accessibleContext -> getAccessibleChild(0);
- if ( rxAccessible.is() ) {
- Reference < XAccessibleContext > rxAccessibleContext = rxAccessible -> getAccessibleContext();
- if ( rxAccessibleContext.is() && rxAccessibleContext -> getAccessibleRole() == AccessibleRole::TEXT ) {
- sal_Int64 nStateSet = rxAccessibleContext -> getAccessibleStateSet();
- if ( !(nStateSet & AccessibleStateType::EDITABLE ) ) {
- [ nativeRole release ];
- nativeRole = NSAccessibilityPopUpButtonRole;
+ try {
+ Reference < XAccessible > rxAccessible = accessibleContext -> getAccessibleChild(0);
+ if ( rxAccessible.is() ) {
+ Reference < XAccessibleContext > rxAccessibleContext = rxAccessible -> getAccessibleContext();
+ if ( rxAccessibleContext.is() && rxAccessibleContext -> getAccessibleRole() == AccessibleRole::TEXT ) {
+ sal_Int64 nStateSet = rxAccessibleContext -> getAccessibleStateSet();
+ if ( !(nStateSet & AccessibleStateType::EDITABLE ) ) {
+ [ nativeRole release ];
+ nativeRole = NSAccessibilityPopUpButtonRole;
+ }
}
}
}
+ catch (const IndexOutOfBoundsException&)
+ {
+ SAL_WARN("vcl", "No valid accessible objects in parent");
+ }
}
return nativeRole;
}