diff --git a/accessible/src/atk/nsAccessibleHyperText.cpp b/accessible/src/atk/nsAccessibleHyperText.cpp index 88e8ef7db56a..d9ad9493bfc6 100644 --- a/accessible/src/atk/nsAccessibleHyperText.cpp +++ b/accessible/src/atk/nsAccessibleHyperText.cpp @@ -41,6 +41,7 @@ #include "nsAccessibilityService.h" #include "nsAccessibleHyperText.h" #include "nsHTMLLinkAccessibleWrap.h" +#include "nsPIAccessNode.h" #include "nsIFrame.h" #include "nsILink.h" #include "nsIServiceManager.h" @@ -412,15 +413,18 @@ NS_IMETHODIMP nsAccessibleHyperText::GetLink(PRInt32 aIndex, nsIAccessibleHyperL if (cachedAcc) { // Retrieved from cache nsCOMPtr cachedLink(do_QueryInterface(cachedAcc)); - if (cachedLink) + if (cachedLink) { *aLink = cachedLink; + NS_IF_ADDREF(*aLink); + } } if (!(*aLink)) { *aLink = new nsHTMLLinkAccessibleWrap(parentNode, weakShell); - nsCOMPtr accessNode(do_QueryInterface(*aLink)); + NS_ENSURE_TRUE(*aLink, NS_ERROR_OUT_OF_MEMORY); + NS_ADDREF(*aLink); + nsCOMPtr accessNode(do_QueryInterface(*aLink)); accessNode->Init(); } - NS_IF_ADDREF(*aLink); break; } } diff --git a/accessible/src/atk/nsMaiInterfaceHypertext.cpp b/accessible/src/atk/nsMaiInterfaceHypertext.cpp index b2869939e35f..82762de50433 100644 --- a/accessible/src/atk/nsMaiInterfaceHypertext.cpp +++ b/accessible/src/atk/nsMaiInterfaceHypertext.cpp @@ -40,6 +40,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsMaiInterfaceHypertext.h" +#include "nsPIAccessNode.h" G_BEGIN_DECLS @@ -150,11 +151,12 @@ getLinkCB(AtkHypertext *aText, gint aLinkIndex) // if the maiHyperlink is not in cache, create it. if (!maiNode) { maiNode = new MaiHyperlink(hyperLink, nsnull, weakShell); - maiNode->Init(); // add to cache. if (!maiNode) { NS_WARNING("OUT OF MEMORY"); return nsnull; } + nsCOMPtr pMaiNode = do_QueryInterface(maiNode); + pMaiNode->Init(); // add to cache. } // we can get AtkHyperlink from the MaiHyperlink