Bug #13017 Updated: mb_strimwidth() - null character in result

From: Date: Wed, 29 Aug 2001 11:12:39 +0000
Subject: Bug #13017 Updated: mb_strimwidth() - null character in result
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-64585@lists.php.net to get a copy of this message
ID: 13017
Updated by: wez
Reported By: tsukada@fminn.nagano.nagano.jp
Old Status: Open
Status: Closed
Bug Type: Unknown/Other Function
Operating System: Redhat 7.1
PHP Version: 4.0CVS-2001-08-29
New Comment:

Fixed in CVS - thanks for the patch.
--Wez.

Previous Comments:
------------------------------------------------------------------------

[2001-08-29 03:27:29] tsukada@fminn.nagano.nagano.jp

In some case, mb_strimwidth() add null character to tail of result.

Script:

<?php
   echo bin2hex( mb_strimwidth('abcdef', 0, 6, '..>') );
?>


Result:

  61626364656600


Patch:

===================================================================
RCS file: /repository/php4/ext/mbstring/mbfilter.c,v
retrieving revision 1.15
diff -u -r1.15 mbfilter.c
--- mbfilter.c  28 Aug 2001 21:50:29 -0000      1.15
+++ mbfilter.c  29 Aug 2001 07:16:54 -0000
@@ -7061,10 +7061,10 @@
        n = string->len;
        if (p != NULL) {
                while (n > 0) {
+                       n--;
                        if ((*encoder->filter_function)(*p++, encoder) < 0) {
                                break;
                        }
-                       n--;
                }
                mbfl_convert_filter_flush(encoder);
                if (pc.status != 0 && mkwidth > 0) {




------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=13017&edit=1



Thread (2 messages)

« previous php.dev (#64585) next »