diff options
author | Antony Dovgal <tony2001@php.net> | 2009-12-08 12:12:23 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2009-12-08 12:12:23 +0000 |
commit | 754c06c6c52879ed770e8f742701b1636d1af530 (patch) | |
tree | 9fd7b9cedb8e1b68a341b98baccac2025486cbdb | |
parent | 8413e1771cbe14e7d2100d0efc65ebb75936b36c (diff) | |
download | php-git-754c06c6c52879ed770e8f742701b1636d1af530.tar.gz |
sync with 5_3
-rw-r--r-- | ext/iconv/iconv.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index d6c55ce627..487ec67eaf 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -740,36 +740,39 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval, if (err != PHP_ICONV_ERR_SUCCESS) { return err; } - - /* normalize the offset and the length */ - if (offset < 0) { - if ((offset += total_len) < 0) { - offset = 0; - } - } + if (len < 0) { if ((len += (total_len - offset)) < 0) { - len = 0; + return PHP_ICONV_ERR_SUCCESS; } } - if((unsigned int) len > total_len) { + if (offset < 0) { + if ((offset += total_len) < 0) { + return PHP_ICONV_ERR_SUCCESS; + } + } + + if(len > total_len) { len = total_len; } - if ((unsigned int) offset >= total_len) { + + if (offset >= total_len) { return PHP_ICONV_ERR_SUCCESS; } - if ((unsigned int) (offset + len) > total_len) { + if ((offset + len) > total_len ) { /* trying to compute the length */ len = total_len - offset; } if (len == 0) { + smart_str_appendl(pretval, "", 0); + smart_str_0(pretval); return PHP_ICONV_ERR_SUCCESS; } - + cd1 = iconv_open(GENERIC_SUPERSET_NAME, enc); if (cd1 == (iconv_t)(-1)) { |