summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-08-17 16:51:27 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-19 14:24:28 +0200
commit6a040d5c81cbca0de6290d363a20b4329d1456f8 (patch)
tree8b8606dcddb9704736515789e7ed52d3684449e1 /src/platformsupport/linuxaccessibility/atspiadaptor.cpp
parent7495b59dbda45049ba54f3682904962c217a9906 (diff)
Fix potential division by zero
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 <jan-arve.saether@digia.com>
Diffstat (limited to 'src/platformsupport/linuxaccessibility/atspiadaptor.cpp')
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor.cpp21
1 files changed, 13 insertions, 8 deletions
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;