mirror of
https://github.com/php/php-src.git
synced 2026-04-27 10:16:41 +02:00
- Added check for encoding optional parameter (avoiding the segfault in filter.c: strlen(encoding))
If the parameter is not suplied, it will try to use the UG(stream_enconding)
This commit is contained in:
@@ -1578,6 +1578,14 @@ PHP_FUNCTION(stream_encoding)
|
||||
if (remove_write_tail) {
|
||||
php_stream_filter_remove(stream->writefilters.tail, 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
if (encoding_len == 0) {
|
||||
if (UG(stream_encoding) == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The stream_encoding must be defined");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
encoding = UG(stream_encoding);
|
||||
}
|
||||
|
||||
/* UTODO: Allow overriding error handling for converters */
|
||||
php_stream_encoding_apply(stream, 1, encoding, UG(from_error_mode), UG(from_subst_char));
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Testing stream_encoding()
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
stream_encoding(fopen(__FILE__, 'r'));
|
||||
print "Done";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Done
|
||||
Reference in New Issue
Block a user