From ce3c028803aa7254be4d612703e8907c5fd95f4f Mon Sep 17 00:00:00 2001 From: Moriyoshi Koizumi Date: Wed, 23 Sep 2009 15:22:47 +0000 Subject: [PATCH] - Fixed bug #49354 (mb_strcut() cuts wrong length when offset is within a multibyte character). (This bug was introduced by the commit by r202895. Please double-check the specification of the function you are going to *fix*.) --- ext/mbstring/mbstring.c | 4 ---- ext/mbstring/tests/bug49354.phpt | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 ext/mbstring/tests/bug49354.phpt diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 51dd2d7481..6d89868284 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -2664,10 +2664,6 @@ PHP_FUNCTION(mb_strcut) RETURN_FALSE; } - if (((unsigned int)from + (unsigned int)len) > string.len) { - len = string.len - from; - } - ret = mbfl_strcut(&string, &result, from, len); if (ret == NULL) { RETURN_FALSE; diff --git a/ext/mbstring/tests/bug49354.phpt b/ext/mbstring/tests/bug49354.phpt new file mode 100644 index 0000000000..c25b405d82 --- /dev/null +++ b/ext/mbstring/tests/bug49354.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #49354 (mb_strcut() cuts wrong length when offset is in the middle of a multibyte character) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(12) "AåBäCöDü" +string(11) "åBäCöDü" +string(11) "åBäCöDü" +string(9) "BäCöDü" +string(0) "" +bool(false) -- 2.40.0