File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,9 @@ PHP NEWS
6161- Iconv:
6262 . Fixed bug GH-17047 (UAF on iconv filter failure). (nielsdos)
6363
64+ - LibXML:
65+ . Fixed bug GH-17223 (Memory leak in libxml encoding handling). (nielsdos)
66+
6467- MBString:
6568 . Fixed bug GH-17112 (Macro redefinitions). (nielsdos, cmb)
6669
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-17223 (Memory leak in libxml encoding handling)
3+ --EXTENSIONS--
4+ dom
5+ --FILE--
6+ <?php
7+ $ doc = new DOMDocument ("1.0 " , "Shift-JIS " );
8+ @$ doc ->save ("%00 " );
9+ echo "Done \n" ;
10+ ?>
11+ --EXPECT--
12+ Done
Original file line number Diff line number Diff line change @@ -562,11 +562,11 @@ php_libxml_output_buffer_create_filename(const char *URI,
562562 char * unescaped = NULL ;
563563
564564 if (URI == NULL )
565- return ( NULL ) ;
565+ goto err ;
566566
567567 if (strstr (URI , "%00" )) {
568568 php_error_docref (NULL , E_WARNING , "URI must not contain percent-encoded NUL bytes" );
569- return NULL ;
569+ goto err ;
570570 }
571571
572572 puri = xmlParseURI (URI );
@@ -587,7 +587,7 @@ php_libxml_output_buffer_create_filename(const char *URI,
587587 }
588588
589589 if (context == NULL ) {
590- return ( NULL ) ;
590+ goto err ;
591591 }
592592
593593 /* Allocate the Output buffer front-end. */
@@ -599,6 +599,11 @@ php_libxml_output_buffer_create_filename(const char *URI,
599599 }
600600
601601 return (ret );
602+
603+ err :
604+ /* Similarly to __xmlOutputBufferCreateFilename we should also close the encoder on failure. */
605+ xmlCharEncCloseFunc (encoder );
606+ return NULL ;
602607}
603608
604609static void _php_libxml_free_error (void * ptr )
You can’t perform that action at this time.
0 commit comments