File tree 3 files changed +23
-3
lines changed
3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,9 @@ PHP NEWS
61
61
- Iconv:
62
62
. Fixed bug GH-17047 (UAF on iconv filter failure). (nielsdos)
63
63
64
+ - LibXML:
65
+ . Fixed bug GH-17223 (Memory leak in libxml encoding handling). (nielsdos)
66
+
64
67
- MBString:
65
68
. Fixed bug GH-17112 (Macro redefinitions). (nielsdos, cmb)
66
69
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,
562
562
char * unescaped = NULL ;
563
563
564
564
if (URI == NULL )
565
- return ( NULL ) ;
565
+ goto err ;
566
566
567
567
if (strstr (URI , "%00" )) {
568
568
php_error_docref (NULL , E_WARNING , "URI must not contain percent-encoded NUL bytes" );
569
- return NULL ;
569
+ goto err ;
570
570
}
571
571
572
572
puri = xmlParseURI (URI );
@@ -587,7 +587,7 @@ php_libxml_output_buffer_create_filename(const char *URI,
587
587
}
588
588
589
589
if (context == NULL ) {
590
- return ( NULL ) ;
590
+ goto err ;
591
591
}
592
592
593
593
/* Allocate the Output buffer front-end. */
@@ -599,6 +599,11 @@ php_libxml_output_buffer_create_filename(const char *URI,
599
599
}
600
600
601
601
return (ret );
602
+
603
+ err :
604
+ /* Similarly to __xmlOutputBufferCreateFilename we should also close the encoder on failure. */
605
+ xmlCharEncCloseFunc (encoder );
606
+ return NULL ;
602
607
}
603
608
604
609
static void _php_libxml_free_error (void * ptr )
You can’t perform that action at this time.
0 commit comments