QCocoaA(11)y: do not try to access an element if rowIndex == -1

This ends up in out of bounds exception.

Pick-to: 6.7 6.6 6.5 6.6.2
Fixes: QTBUG-120469
Fixes: QTBUG-121008
Change-Id: Id895f311bbb59a3734ecadd0d2472a4018332e16
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Timur Pocheptsov 2024-01-15 15:15:12 +01:00
parent 15b0bd69ff
commit 75a918d487

View File

@ -563,7 +563,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
else if (QAccessibleTableCellInterface *cell = iface->tableCellInterface())
rowIndex = cell->rowIndex();
Q_ASSERT(tableElement->rows);
if (rowIndex > int([tableElement->rows count]))
if (rowIndex > int([tableElement->rows count]) || rowIndex == -1)
return nil;
QMacAccessibilityElement *rowElement = tableElement->rows[rowIndex];
return NSAccessibilityUnignoredAncestor(rowElement);