From: Felipe Pena Date: Wed, 28 May 2008 18:02:52 +0000 (+0000) Subject: - Added check for encoding optional parameter (avoiding the segfault in filter.c... X-Git-Tag: BEFORE_HEAD_NS_CHANGE~1636 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e4fc964ab335e90fc2ca9212c937037dffbe89de;p=php - 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) --- diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index cb6b007667..14bcebb2e7 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -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)); diff --git a/ext/standard/tests/streams/stream_encoding.phpt b/ext/standard/tests/streams/stream_encoding.phpt new file mode 100644 index 0000000000..e92fda55b7 --- /dev/null +++ b/ext/standard/tests/streams/stream_encoding.phpt @@ -0,0 +1,11 @@ +--TEST-- +Testing stream_encoding() +--FILE-- + +--EXPECT-- +Done