Do not crash if the child index is out of range.

Task-number: QTBUG-29077

Change-Id: I934101cdc121e9ef99de2e9eeaef154dd4cae0d8
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
This commit is contained in:
Jan Arve Saether 2013-02-05 16:43:07 +01:00 committed by The Qt Project
parent af84313c62
commit 20204fe58b
2 changed files with 9 additions and 3 deletions

View File

@ -577,9 +577,10 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::accLocation(long *pxLeft, long
QRect rect;
if (varID.lVal) {
QAIPointer child = QAIPointer(accessible->child(varID.lVal - 1));
if (child->isValid())
rect = child->rect();
QAIPointer child(childPointer(varID));
if (!child)
return E_FAIL;
rect = child->rect();
} else {
rect = accessible->rect();
}

View File

@ -3113,6 +3113,11 @@ void tst_QAccessibility::bridgeTest()
// **** Test accLocation ****
long x, y, w, h;
// Do not crash on insane arguments.
varChild.lVal = 999;
hr = iaccButton->accLocation(&x, &y, &w, &h, varChild);
QCOMPARE(SUCCEEDED(hr), false);
hr = iaccButton->accLocation(&x, &y, &w, &h, varSELF);
QCOMPARE(buttonRect, QRect(x, y, w, h));