summaryrefslogtreecommitdiff
path: root/ext/iconv
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-11-15 18:34:57 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-11-15 18:34:57 +0000
commit82fb3e00b8259d6be0c1d2274069d4235846e6d6 (patch)
tree74ef854f534316eaa068452d6d461d5a6674bcd7 /ext/iconv
parent3f92ab719f8c40041fd80c7d52a7eb8771fbeed7 (diff)
downloadphp-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.c8
-rw-r--r--ext/iconv/tests/bug37773.phpt10
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