diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2006-11-15 18:34:57 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2006-11-15 18:34:57 +0000 |
commit | 82fb3e00b8259d6be0c1d2274069d4235846e6d6 (patch) | |
tree | 74ef854f534316eaa068452d6d461d5a6674bcd7 /ext/iconv | |
parent | 3f92ab719f8c40041fd80c7d52a7eb8771fbeed7 (diff) | |
download | php-git-82fb3e00b8259d6be0c1d2274069d4235846e6d6.tar.gz |
Fixed bug #37773 (iconv_substr() gives "Unknown error" when string length =
1").
Diffstat (limited to 'ext/iconv')
-rw-r--r-- | ext/iconv/iconv.c | 8 | ||||
-rw-r--r-- | ext/iconv/tests/bug37773.phpt | 10 |
2 files changed, 13 insertions, 5 deletions
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-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + var_dump(iconv_substr('x', 0, 1, 'UTF-8')); +?> +--EXPECT-- +string(1) "x"
\ No newline at end of file |