From 6a040d5c81cbca0de6290d363a20b4329d1456f8 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sat, 17 Aug 2013 16:51:27 +0200 Subject: Fix potential division by zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since it's possible to call the function on an empty model, return failure in that case. Change-Id: I0a0eabe917da3e6294bdd616a85579f6dc894ec8 Reviewed-by: Jan Arve Sæther --- .../linuxaccessibility/atspiadaptor.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/platformsupport/linuxaccessibility') diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 6efd5085ac..d42251d4dd 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -2230,16 +2230,21 @@ bool AtSpiAdaptor::tableInterface(QAccessibleInterface *interface, const QString int index = message.arguments().at(0).toInt(); bool success = false; - int row, col, rowExtents, colExtents; - bool isSelected; + int row = -1; + int col = -1; + int rowExtents = -1; + int colExtents = -1; + bool isSelected = false; int cols = interface->tableInterface()->columnCount(); - row = index/cols; - col = index%cols; - QAccessibleTableCellInterface *cell = interface->tableInterface()->cellAt(row, col)->tableCellInterface(); - if (cell) { - cell->rowColumnExtents(&row, &col, &rowExtents, &colExtents, &isSelected); - success = true; + if (cols > 0) { + row = index / cols; + col = index % cols; + QAccessibleTableCellInterface *cell = interface->tableInterface()->cellAt(row, col)->tableCellInterface(); + if (cell) { + cell->rowColumnExtents(&row, &col, &rowExtents, &colExtents, &isSelected); + success = true; + } } QVariantList list; -- cgit v1.2.3