From: Ilia Alshanetsky Date: Wed, 15 Nov 2006 18:35:18 +0000 (+0000) Subject: MFB: Fixed bug #37773 (iconv_substr() gives "Unknown error" when string X-Git-Tag: RELEASE_1_0_0RC1~996 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0252643b32bc5b4233a577723d96625de8bb6fdf;p=php MFB: Fixed bug #37773 (iconv_substr() gives "Unknown error" when string length = 1"). --- diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 7df2240f95..832d2dca76 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -809,7 +809,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; } @@ -827,10 +829,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