mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Throw early when a non-stream-context resource is passed to libxml_set_streams_context() (#14279)
This commit is contained in:
2
NEWS
2
NEWS
@@ -98,6 +98,8 @@ PHP NEWS
|
||||
|
||||
- LibXML:
|
||||
. Added LIBXML_RECOVER constant. (nielsdos)
|
||||
. libxml_set_streams_context() now throws immediately on an invalid context
|
||||
instead of at the use-site. (nielsdos)
|
||||
|
||||
- MBString:
|
||||
. Added mb_trim, mb_ltrim and mb_rtrim. (Yuya Hamada)
|
||||
|
||||
@@ -383,6 +383,11 @@ PHP 8.4 UPGRADE NOTES
|
||||
. ResourceBundle::get() now has a tentative return type of:
|
||||
ResourceBundle|array|string|int|null
|
||||
|
||||
- LibXML:
|
||||
. libxml_set_streams_context() now immediately throws a TypeError when a
|
||||
non-stream-context resource is passed to the function, instead of throwing
|
||||
later when the stream context is used.
|
||||
|
||||
- MBString:
|
||||
. The behavior of mb_strcut is more consistent now on invalid UTF-8 and UTF-16
|
||||
strings. (For valid UTF-8 and UTF-16 strings, there is no change.)
|
||||
|
||||
@@ -1049,10 +1049,12 @@ PHP_FUNCTION(libxml_set_streams_context)
|
||||
Z_PARAM_RESOURCE(arg)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (!Z_ISUNDEF(LIBXML(stream_context))) {
|
||||
zval_ptr_dtor(&LIBXML(stream_context));
|
||||
if (php_stream_context_from_zval(arg, true) != NULL) {
|
||||
if (!Z_ISUNDEF(LIBXML(stream_context))) {
|
||||
zval_ptr_dtor(&LIBXML(stream_context));
|
||||
}
|
||||
ZVAL_COPY(&LIBXML(stream_context), arg);
|
||||
}
|
||||
ZVAL_COPY(&LIBXML(stream_context), arg);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
@@ -4,15 +4,20 @@ Bug #63389 (Missing context check on libxml_set_streams_context() causes memleak
|
||||
libxml
|
||||
--FILE--
|
||||
<?php
|
||||
$fp = fopen("php://input", "r");
|
||||
libxml_set_streams_context($fp);
|
||||
try {
|
||||
libxml_set_streams_context("a");
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
$fp = fopen("php://input", "r");
|
||||
try {
|
||||
libxml_set_streams_context($fp);
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
echo "okey";
|
||||
?>
|
||||
--EXPECT--
|
||||
libxml_set_streams_context(): Argument #1 ($context) must be of type resource, string given
|
||||
libxml_set_streams_context(): supplied resource is not a valid Stream-Context resource
|
||||
okey
|
||||
|
||||
Reference in New Issue
Block a user