Fix possible crash due to misuse of nsCOMPtr. Bug 238005, r=caillon,

sr=peterv, a=asa
This commit is contained in:
bzbarsky%mit.edu 2004-03-31 15:15:59 +00:00
parent f4f167dc73
commit d088ac5727

View File

@ -1024,13 +1024,15 @@ nsHTMLSelectElement::Add(nsIDOMHTMLElement* aElement,
}
nsCOMPtr<nsIDOMNode> ancestor(parent);
nsCOMPtr<nsIDOMNode> temp;
while (ancestor != NS_STATIC_CAST(nsIDOMNode*, this)) {
ancestor->GetParentNode(getter_AddRefs(ancestor));
if (!ancestor) {
ancestor->GetParentNode(getter_AddRefs(temp));
if (!temp) {
// NOT_FOUND_ERR: Raised if before is not a descendant of the SELECT
// element.
return NS_ERROR_DOM_NOT_FOUND_ERR;
}
temp.swap(ancestor);
}
// If the before parameter is not null, we are equivalent to the