From e4fc964ab335e90fc2ca9212c937037dffbe89de Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Wed, 28 May 2008 18:02:52 +0000 Subject: [PATCH] - 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) --- ext/standard/streamsfuncs.c | 8 ++++++++ ext/standard/tests/streams/stream_encoding.phpt | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 ext/standard/tests/streams/stream_encoding.phpt 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 -- 2.50.1