Bug 1419362 part 1: Make IAccessibleHypertext2::hyperlinks return null and S_FALSE when there are no hyperlinks. r?MarcoZ
As per the spec, if there are no hyperlinks, the hyperlinks array should be set to null and S_FALSE should be returned.
This saves pointless memory management when there are no hyperlinks.
MozReview-Commit-ID: 9wsiXBely6G
--- a/accessible/windows/ia2/ia2AccessibleHypertext.cpp
+++ b/accessible/windows/ia2/ia2AccessibleHypertext.cpp
@@ -95,16 +95,21 @@ ia2AccessibleHypertext::get_hyperlinks(I
HyperTextAccessibleWrap* hyperText = static_cast<HyperTextAccessibleWrap*>(this);
if (hyperText->IsDefunct()) {
return CO_E_OBJNOTCONNECTED;
}
uint32_t count = hyperText->LinkCount();
*aNHyperlinks = count;
+ if (count == 0) {
+ *aHyperlinks = nullptr;
+ return S_FALSE;
+ }
+
*aHyperlinks = static_cast<IAccessibleHyperlink**>(::CoTaskMemAlloc(
sizeof(IAccessibleHyperlink*) * count));
if (!*aHyperlinks) {
return E_OUTOFMEMORY;
}
for (uint32_t i = 0; i < count; ++i) {
AccessibleWrap* hyperLink =