]> granicus.if.org Git - php/commitdiff
better fix for iconv_substr
authorStanislav Malyshev <stas@php.net>
Thu, 20 Sep 2007 22:38:25 +0000 (22:38 +0000)
committerStanislav Malyshev <stas@php.net>
Thu, 20 Sep 2007 22:38:25 +0000 (22:38 +0000)
ext/iconv/iconv.c

index 2386bdebbabf6138e98378806d877e40fbc22dd0..9e728115100b9a54991b0ce9c0ddd78d2525f6db 100644 (file)
@@ -765,10 +765,14 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval,
                }
        }
 
-       if (offset >= total_len || len > total_len) {
+       if(len > total_len) {
+               len = total_len;
+       }
+
+       if (offset >= total_len) {
                return PHP_ICONV_ERR_SUCCESS;
        }
-       
+
        if ((offset + len) > total_len) {
                /* trying to compute the length */
                len = total_len - offset;