File tree Expand file tree Collapse file tree 4 files changed +8
-78
lines changed Expand file tree Collapse file tree 4 files changed +8
-78
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ PHP NEWS
22
22
(nielsdos)
23
23
. Fix crash when toggleAttribute() is used without a document. (nielsdos)
24
24
. Fix crash in adoptNode with attribute references. (nielsdos)
25
- . Fix crashes with entity references and predefined entities. (nielsdos)
26
25
27
26
- FFI:
28
27
. Fixed bug GH-9698 (stream_wrapper_register crashes with FFI\CData).
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -9,32 +9,16 @@ $doc->loadXML(<<<'XML'
9
9
<?xml version="1.0"?>
10
10
<!DOCTYPE books [
11
11
<!ENTITY test "entity is only for test purposes">
12
- <!ENTITY myimage PUBLIC "-" "mypicture.gif" NDATA GIF>
13
12
]>
14
13
<container/>
15
14
XML);
16
- $ ref1 = $ doc ->createEntityReference ("test " );
17
- $ ref2 = $ doc ->createEntityReference ("myimage " );
18
- $ entity1 = $ doc ->doctype ->entities [0 ];
19
- $ entity2 = $ doc ->doctype ->entities [1 ];
20
-
21
- // Entity order depends on addresses
22
- if ($ entity1 ->nodeName !== "test " ) {
23
- [$ entity1 , $ entity2 ] = [$ entity2 , $ entity1 ];
24
- }
25
-
26
- var_dump ($ entity1 ->nodeName , $ entity1 ->parentNode ->nodeName );
27
- var_dump ($ entity2 ->nodeName , $ entity2 ->parentNode ->nodeName );
15
+ $ entity = $ doc ->doctype ->entities [0 ];
16
+ var_dump ($ entity ->nodeName , $ entity ->parentNode ->nodeName );
28
17
$ doc ->removeChild ($ doc ->doctype );
29
- var_dump ($ entity1 ->nodeName , $ entity1 ->parentNode );
30
- var_dump ($ entity2 ->nodeName , $ entity2 ->parentNode );
18
+ var_dump ($ entity ->nodeName , $ entity ->parentNode );
31
19
?>
32
20
--EXPECT--
33
21
string(4) "test"
34
22
string(5) "books"
35
- string(7) "myimage"
36
- string(5) "books"
37
23
string(4) "test"
38
24
NULL
39
- string(7) "myimage"
40
- NULL
Original file line number Diff line number Diff line change @@ -207,10 +207,12 @@ static void php_libxml_node_free(xmlNodePtr node)
207
207
* dtd is attached to the document. This works around the issue by inspecting the parent directly. */
208
208
case XML_ENTITY_DECL : {
209
209
xmlEntityPtr entity = (xmlEntityPtr ) node ;
210
- if (entity -> etype != XML_INTERNAL_PREDEFINED_ENTITY ) {
211
- php_libxml_unlink_entity_decl (entity );
212
- xmlFreeEntity (entity );
210
+ php_libxml_unlink_entity_decl (entity );
211
+ if (entity -> orig != NULL ) {
212
+ xmlFree ((char * ) entity -> orig );
213
+ entity -> orig = NULL ;
213
214
}
215
+ xmlFreeNode (node );
214
216
break ;
215
217
}
216
218
case XML_NOTATION_NODE : {
@@ -1384,15 +1386,6 @@ PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node)
1384
1386
case XML_DOCUMENT_NODE :
1385
1387
case XML_HTML_DOCUMENT_NODE :
1386
1388
break ;
1387
- case XML_ENTITY_REF_NODE :
1388
- /* Entity reference nodes are special: their children point to entity declarations,
1389
- * but they don't own the declarations and therefore shouldn't free the children.
1390
- * Moreover, there can be N>1 reference nodes for a single entity declarations. */
1391
- php_libxml_unregister_node (node );
1392
- if (node -> parent == NULL ) {
1393
- php_libxml_node_free (node );
1394
- }
1395
- break ;
1396
1389
default :
1397
1390
if (node -> parent == NULL || node -> type == XML_NAMESPACE_DECL ) {
1398
1391
php_libxml_node_free_list ((xmlNodePtr ) node -> children );
You can’t perform that action at this time.
0 commit comments