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
2222 (nielsdos)
2323 . Fix crash when toggleAttribute() is used without a document. (nielsdos)
2424 . Fix crash in adoptNode with attribute references. (nielsdos)
25- . Fix crashes with entity references and predefined entities. (nielsdos)
2625
2726- FFI:
2827 . 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'
99<?xml version="1.0"?>
1010<!DOCTYPE books [
1111<!ENTITY test "entity is only for test purposes">
12- <!ENTITY myimage PUBLIC "-" "mypicture.gif" NDATA GIF>
1312]>
1413<container/>
1514XML);
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 );
2817$ 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 );
3119?>
3220--EXPECT--
3321string(4) "test"
3422string(5) "books"
35- string(7) "myimage"
36- string(5) "books"
3723string(4) "test"
3824NULL
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)
207207 * dtd is attached to the document. This works around the issue by inspecting the parent directly. */
208208 case XML_ENTITY_DECL : {
209209 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 ;
213214 }
215+ xmlFreeNode (node );
214216 break ;
215217 }
216218 case XML_NOTATION_NODE : {
@@ -1384,15 +1386,6 @@ PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node)
13841386 case XML_DOCUMENT_NODE :
13851387 case XML_HTML_DOCUMENT_NODE :
13861388 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 ;
13961389 default :
13971390 if (node -> parent == NULL || node -> type == XML_NAMESPACE_DECL ) {
13981391 php_libxml_node_free_list ((xmlNodePtr ) node -> children );
You can’t perform that action at this time.
0 commit comments