From 82fb3e00b8259d6be0c1d2274069d4235846e6d6 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 15 Nov 2006 18:34:57 +0000 Subject: [PATCH] Fixed bug #37773 (iconv_substr() gives "Unknown error" when string length = 1"). --- NEWS | 2 ++ ext/iconv/iconv.c | 8 +++----- ext/iconv/tests/bug37773.phpt | 10 ++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 ext/iconv/tests/bug37773.phpt diff --git a/NEWS b/NEWS index 9b6f91436f..e161130ce2 100644 --- a/NEWS +++ b/NEWS @@ -81,6 +81,8 @@ PHP NEWS (Dmitry) - Fixed bug #38456 (Apache2 segfaults when virtual() is called in .php ErrorDocument). (Ilia) +- Fixed bug #37773 (iconv_substr() gives "Unknown error" when string length = 1"). + (Ilia) - Fixed bug #36975 (natcasesort() causes array_pop() to misbehave). (Hannes) - Fixed bug #36812 (pg_execute() modifies input array). (Ilia) - Fixed bug #36644 (possible crash in variant_date_from_timestamp()). (Ilia) diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 492157024d..e6840e8f41 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -744,7 +744,9 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval, } } - _php_iconv_appendl(pretval, buf, sizeof(buf), cd2); + if (_php_iconv_appendl(pretval, buf, sizeof(buf), cd2) != PHP_ICONV_ERR_SUCCESS) { + break; + } --len; } @@ -762,10 +764,6 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval, case E2BIG: break; - - default: - err = PHP_ICONV_ERR_UNKNOWN; - break; } #endif if (err == PHP_ICONV_ERR_SUCCESS) { diff --git a/ext/iconv/tests/bug37773.phpt b/ext/iconv/tests/bug37773.phpt new file mode 100644 index 0000000000..f55c153b85 --- /dev/null +++ b/ext/iconv/tests/bug37773.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #37773 (iconv_substr() gives "Unknown error" when string length = 1") +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(1) "x" \ No newline at end of file -- 2.40.0