From bda9b87fdb1bb03a63a155b93103a91886db3908 Mon Sep 17 00:00:00 2001 From: James Teh Date: Mon, 19 Aug 2019 05:58:49 +0000 Subject: [PATCH] Bug 1574428: IAccessible2_2::relationTargetsOfType: Support 0 for all targets and fix off-by-one error. r=MarcoZ 1. As per the spec, if maxTargets is 0, return all targets. 2. Where maxTargets > 0, fix the loop condition so it doesn't incorrectly fetch one more target than requested. Differential Revision: https://phabricator.services.mozilla.com/D42446 --HG-- extra : moz-landing-system : lando --- accessible/windows/ia2/ia2Accessible.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/accessible/windows/ia2/ia2Accessible.cpp b/accessible/windows/ia2/ia2Accessible.cpp index 66edac98e955..b68a9033ceab 100644 --- a/accessible/windows/ia2/ia2Accessible.cpp +++ b/accessible/windows/ia2/ia2Accessible.cpp @@ -493,8 +493,9 @@ ia2Accessible::get_relationTargetsOfType(BSTR aType, long aMaxTargets, MOZ_ASSERT(!acc->IsProxy()); Relation rel = acc->RelationByType(*relationType); Accessible* target = nullptr; - while ((target = rel.Next()) && - static_cast(targets.Length()) <= aMaxTargets) { + while ( + (target = rel.Next()) && + (aMaxTargets == 0 || static_cast(targets.Length()) < aMaxTargets)) { targets.AppendElement(target); }