Skip to content

Commit 20dfc41

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix crash when toggleAttribute() is used without a document
2 parents 5455c3f + b2d778c commit 20dfc41

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

ext/dom/element.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ PHP_METHOD(DOMElement, toggleAttribute)
15551555
}
15561556

15571557
/* Step 2 */
1558-
if (thisp->doc->type == XML_HTML_DOCUMENT_NODE && (thisp->ns == NULL || xmlStrEqual(thisp->ns->href, (const xmlChar *) "http://www.w3.org/1999/xhtml"))) {
1558+
if (thisp->doc != NULL && thisp->doc->type == XML_HTML_DOCUMENT_NODE && (thisp->ns == NULL || xmlStrEqual(thisp->ns->href, (const xmlChar *) "http://www.w3.org/1999/xhtml"))) {
15591559
qname_tmp = zend_str_tolower_dup_ex(qname, qname_length);
15601560
if (qname_tmp != NULL) {
15611561
qname = qname_tmp;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
DOMElement::toggleAttribute() without a document
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
$element = new DOMElement("container");
9+
$element->toggleAttribute('foo', true);
10+
11+
$dom = new DOMDocument;
12+
$element = $dom->importNode($element, true);
13+
echo $dom->saveXML($element), "\n";
14+
15+
?>
16+
--EXPECT--
17+
<container foo=""/>

0 commit comments

Comments
 (0)