]> granicus.if.org Git - php/commitdiff
MF51 Ilia's last fix
authorAntony Dovgal <tony2001@php.net>
Fri, 16 Dec 2005 14:50:32 +0000 (14:50 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 16 Dec 2005 14:50:32 +0000 (14:50 +0000)
fix the test appropriately

ext/mbstring/mbstring.c
ext/mbstring/tests/mb_strcut.phpt

index 1f7a1c98ca6cd5278d1244f82f8e8927b52cc4a6..14c662d8e5f2d118a2608aa80b18053b5c88a7d3 100644 (file)
@@ -1844,6 +1844,13 @@ PHP_FUNCTION(mb_strcut)
                }
        }
 
+       if (from > Z_STRLEN_PP(arg1)) {
+               RETURN_FALSE;
+       }
+       if (((unsigned) from + (unsigned) len) > Z_STRLEN_PP(arg1)) {
+               len = Z_STRLEN_PP(arg1) - from;
+       }
+       
        ret = mbfl_strcut(&string, &result, from, len);
        if (ret != NULL) {
                RETVAL_STRINGL(ret->val, ret->len, 0);          /* the string is already strdup()'ed */
index 8ea074a3cda302d3b59121c478b35f5e0d96fac1..6a90d87d208294899ee10d47c7f171c3faf50c78 100644 (file)
@@ -17,7 +17,7 @@ print  mb_strcut($euc_jp,  6,   5,'EUC-JP') . "\n";
 print  mb_strcut($euc_jp,  0, 100,'EUC-JP') . "\n";
 
 $str = mb_strcut($euc_jp, 100, 10,'EUC-JP');
-($str === "") ? print "OK\n" : print "NG: $str\n";
+($str === false) ? print "OK\n" : print "NG: $str\n";
 
 $str = mb_strcut($euc_jp, -100, 10,'EUC-JP');
 ($str !== "") ?        print "OK: $str\n" : print "NG:\n";