php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13017 mb_strimwidth() - null character in result
Submitted: 2001-08-29 03:27 UTC Modified: 2001-08-29 07:12 UTC
From: tsukada at fminn dot nagano dot nagano dot jp Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.0CVS-2001-08-29 OS: Redhat 7.1
Private report: No CVE-ID: None
 [2001-08-29 03:27 UTC] tsukada at fminn dot nagano dot nagano dot 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) {



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-29 07:12 UTC] wez@php.net
Fixed in CVS - thanks for the patch.
--Wez.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 16:01:29 2024 UTC