diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2016-08-30 01:07:20 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2016-08-30 01:16:45 +0200 |
commit | 4b45c0a9a7d48a69edba9e00270c49bbe17af4d1 (patch) | |
tree | 6914efaff015d1815e4539e71b2681adfaf8b2ab | |
parent | 1b227de970deede1592ba08d8b93522937d7d19c (diff) | |
parent | a837b2f6a35ab7cdfb49b9407ac0401caa672b23 (diff) | |
download | php-git-4b45c0a9a7d48a69edba9e00270c49bbe17af4d1.tar.gz |
Merge branch 'pull-request/2043' into PHP-7.0
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/iconv/iconv.c | 4 | ||||
-rw-r--r-- | ext/iconv/tests/bug72320.phpt | 14 |
3 files changed, 19 insertions, 2 deletions
@@ -34,6 +34,9 @@ PHP NEWS images). (cmb) . Fixed bug #68716 (possible resource leaks in _php_image_convert()). (cmb) +- iconv: + . Fixed bug #72320 (iconv_substr returns false for empty strings). (cmb) + - IMAP: . Fixed bug #72852 (imap_mail null dereference). (Anatol) diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index d4a7f6e0af..364882305c 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -858,7 +858,7 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval, } - if ((size_t)offset >= total_len) { + if ((size_t)offset > total_len) { return PHP_ICONV_ERR_SUCCESS; } @@ -2108,7 +2108,7 @@ PHP_FUNCTION(iconv_substr) err = _php_iconv_substr(&retval, ZSTR_VAL(str), ZSTR_LEN(str), offset, length, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset); - if (err == PHP_ICONV_ERR_SUCCESS && ZSTR_LEN(str) > 0 && retval.s != NULL) { + if (err == PHP_ICONV_ERR_SUCCESS && ZSTR_LEN(str) >= 0 && retval.s != NULL) { RETURN_NEW_STR(retval.s); } smart_str_free(&retval); diff --git a/ext/iconv/tests/bug72320.phpt b/ext/iconv/tests/bug72320.phpt new file mode 100644 index 0000000000..0c83d33db0 --- /dev/null +++ b/ext/iconv/tests/bug72320.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #72320 (iconv_substr returns false for empty strings) +--SKIPIF-- +<?php +if (!extension_loaded('iconv')) die('skip ext/iconv required'); +?> +--FILE-- +<?php +var_dump(iconv_substr('', 0, 10, 'UTF-8')); +var_dump(iconv_substr('foo', 3, 10, 'UTF-8')); +?> +--EXPECT-- +string(0) "" +string(0) "" |