File tree 4 files changed +19
-5
lines changed
4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,8 @@ PHP NEWS
98
98
99
99
- LibXML:
100
100
. Added LIBXML_RECOVER constant. (nielsdos)
101
+ . libxml_set_streams_context() now throws immediately on an invalid context
102
+ instead of at the use-site. (nielsdos)
101
103
102
104
- MBString:
103
105
. Added mb_trim, mb_ltrim and mb_rtrim. (Yuya Hamada)
Original file line number Diff line number Diff line change @@ -383,6 +383,11 @@ PHP 8.4 UPGRADE NOTES
383
383
. ResourceBundle::get() now has a tentative return type of:
384
384
ResourceBundle|array|string|int|null
385
385
386
+ - LibXML:
387
+ . libxml_set_streams_context() now immediately throws a TypeError when a
388
+ non-stream-context resource is passed to the function, instead of throwing
389
+ later when the stream context is used.
390
+
386
391
- MBString:
387
392
. The behavior of mb_strcut is more consistent now on invalid UTF-8 and UTF-16
388
393
strings. (For valid UTF-8 and UTF-16 strings, there is no change.)
Original file line number Diff line number Diff line change @@ -1049,10 +1049,12 @@ PHP_FUNCTION(libxml_set_streams_context)
1049
1049
Z_PARAM_RESOURCE (arg )
1050
1050
ZEND_PARSE_PARAMETERS_END ();
1051
1051
1052
- if (!Z_ISUNDEF (LIBXML (stream_context ))) {
1053
- zval_ptr_dtor (& LIBXML (stream_context ));
1052
+ if (php_stream_context_from_zval (arg , true) != NULL ) {
1053
+ if (!Z_ISUNDEF (LIBXML (stream_context ))) {
1054
+ zval_ptr_dtor (& LIBXML (stream_context ));
1055
+ }
1056
+ ZVAL_COPY (& LIBXML (stream_context ), arg );
1054
1057
}
1055
- ZVAL_COPY (& LIBXML (stream_context ), arg );
1056
1058
}
1057
1059
/* }}} */
1058
1060
Original file line number Diff line number Diff line change @@ -4,15 +4,20 @@ Bug #63389 (Missing context check on libxml_set_streams_context() causes memleak
4
4
libxml
5
5
--FILE--
6
6
<?php
7
- $ fp = fopen ("php://input " , "r " );
8
- libxml_set_streams_context ($ fp );
9
7
try {
10
8
libxml_set_streams_context ("a " );
11
9
} catch (TypeError $ e ) {
12
10
echo $ e ->getMessage (), "\n" ;
13
11
}
12
+ $ fp = fopen ("php://input " , "r " );
13
+ try {
14
+ libxml_set_streams_context ($ fp );
15
+ } catch (TypeError $ e ) {
16
+ echo $ e ->getMessage (), "\n" ;
17
+ }
14
18
echo "okey " ;
15
19
?>
16
20
--EXPECT--
17
21
libxml_set_streams_context(): Argument #1 ($context) must be of type resource, string given
22
+ libxml_set_streams_context(): supplied resource is not a valid Stream-Context resource
18
23
okey
You can’t perform that action at this time.
0 commit comments