Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit e73272c

Browse files
committed
Bug 865147 - Fix crash in nsContentUtils::ContentIsDescendantOf by checking parent of 'before' node, r=bz, feedback=Ms2ger
1 parent 96eccc1 commit e73272c

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!doctype html>
2+
<select></select>
3+
<script>
4+
var select = document.getElementsByTagName("select")[0];
5+
var newOpt = document.createElement("option");
6+
select.add(newOpt, newOpt);
7+
</script>

content/html/content/crashtests/crashtests.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ load 832011.html
5151
load 837033.html
5252
pref(dom.experimental_forms_range,true) load 838256-1.html
5353
load 862084.html
54+
load 865147.html

content/html/content/src/HTMLSelectElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ HTMLSelectElement::Add(nsGenericHTMLElement& aElement,
630630
// Just in case we're not the parent, get the parent of the reference
631631
// element
632632
nsINode* parent = aBefore->GetParentNode();
633-
if (!nsContentUtils::ContentIsDescendantOf(parent, this)) {
633+
if (!parent || !nsContentUtils::ContentIsDescendantOf(parent, this)) {
634634
// NOT_FOUND_ERR: Raised if before is not a descendant of the SELECT
635635
// element.
636636
aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);

0 commit comments

Comments
 (0)