diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 98cac27a6804..500c766ecc14 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -575,7 +575,8 @@ fail:; /* {{{ _php_iconv_strlen() */ static php_iconv_err_t _php_iconv_strlen(size_t *pretval, const char *str, size_t nbytes, const char *enc) { - char buf[GENERIC_SUPERSET_NBYTES*2]; + /* A multiple of GENERIC_SUPERSET_NBYTES, large enough to keep the number of iconv() calls low */ + char buf[GENERIC_SUPERSET_NBYTES * 1024]; php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS; diff --git a/ext/iconv/tests/strlen_large_string.phpt b/ext/iconv/tests/strlen_large_string.phpt new file mode 100644 index 000000000000..f4347ad96e0c --- /dev/null +++ b/ext/iconv/tests/strlen_large_string.phpt @@ -0,0 +1,28 @@ +--TEST-- +iconv_strlen(), iconv_substr(): strings around and beyond the conversion buffer size +--EXTENSIONS-- +iconv +--FILE-- + +--EXPECTF-- +string(6) "ééé" +string(3) "abc" +int(4) + +Notice: iconv_strlen(): Detected an illegal character in input string in %s on line %d +bool(false)