Fixing #35605, avoid accessing a null pointer in GetOffsetParent()!

This commit is contained in:
jst%netscape.com 2000-04-13 12:52:03 +00:00
Родитель a73404c364
Коммит 6656f5324e
2 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -624,13 +624,20 @@ nsGenericHTMLElement::GetOffsetHeight(PRInt32* aOffsetHeight)
nsresult nsresult
nsGenericHTMLElement::GetOffsetParent(nsIDOMElement** aOffsetParent) nsGenericHTMLElement::GetOffsetParent(nsIDOMElement** aOffsetParent)
{ {
NS_ENSURE_ARG_POINTER(aOffsetParent);
nsRect rcFrame; nsRect rcFrame;
nsCOMPtr<nsIContent> parent; nsCOMPtr<nsIContent> parent;
nsresult res = GetOffsetRect(rcFrame, nsresult res = GetOffsetRect(rcFrame,
nsHTMLAtoms::body, nsHTMLAtoms::body,
getter_AddRefs(parent)); getter_AddRefs(parent));
if (NS_SUCCEEDED(res)) { if (NS_SUCCEEDED(res)) {
res = parent->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aOffsetParent); if (parent) {
res = parent->QueryInterface(NS_GET_IID(nsIDOMElement),
(void**)aOffsetParent);
} else {
*aOffsetParent = nsnull;
}
} }
return res; return res;
} }

Просмотреть файл

@ -624,13 +624,20 @@ nsGenericHTMLElement::GetOffsetHeight(PRInt32* aOffsetHeight)
nsresult nsresult
nsGenericHTMLElement::GetOffsetParent(nsIDOMElement** aOffsetParent) nsGenericHTMLElement::GetOffsetParent(nsIDOMElement** aOffsetParent)
{ {
NS_ENSURE_ARG_POINTER(aOffsetParent);
nsRect rcFrame; nsRect rcFrame;
nsCOMPtr<nsIContent> parent; nsCOMPtr<nsIContent> parent;
nsresult res = GetOffsetRect(rcFrame, nsresult res = GetOffsetRect(rcFrame,
nsHTMLAtoms::body, nsHTMLAtoms::body,
getter_AddRefs(parent)); getter_AddRefs(parent));
if (NS_SUCCEEDED(res)) { if (NS_SUCCEEDED(res)) {
res = parent->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aOffsetParent); if (parent) {
res = parent->QueryInterface(NS_GET_IID(nsIDOMElement),
(void**)aOffsetParent);
} else {
*aOffsetParent = nsnull;
}
} }
return res; return res;
} }