moriyoshi               Thu Dec 18 04:52:52 2003 EDT

  Added files:                 (Branch: PHP_4_3)
    /php-src/ext/mbstring/tests bug26639.phpt 

  Modified files:              
    /php-src/ext/mbstring       mbstring.c 
    /php-src    NEWS 
  Log:
  MFH(r-1.206): Fixed bug #26639 (mb_convert_variables() clutters variables beyond the 
references)
  
  
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.142.2.41 
php-src/ext/mbstring/mbstring.c:1.142.2.42
--- php-src/ext/mbstring/mbstring.c:1.142.2.41  Wed Dec 10 12:44:12 2003
+++ php-src/ext/mbstring/mbstring.c     Thu Dec 18 04:52:49 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mbstring.c,v 1.142.2.41 2003/12/10 17:44:12 moriyoshi Exp $ */
+/* $Id: mbstring.c,v 1.142.2.42 2003/12/18 09:52:49 moriyoshi Exp $ */
 
 /*
  * PHP4 Multibyte String module "mbstring"
@@ -3283,9 +3283,13 @@
                                                                string.len = 
Z_STRLEN_PP(hash_entry);
                                                                ret = 
mbfl_buffer_converter_feed_result(convd, &string, &result);
                                                                if (ret != NULL) {
-                                                                       
STR_FREE(Z_STRVAL_PP(hash_entry));
-                                                                       
Z_STRVAL_PP(hash_entry) = (char *)ret->val;
-                                                                       
Z_STRLEN_PP(hash_entry) = ret->len;
+                                                                       if 
((*hash_entry)->refcount > 1) {
+                                                                               
ZVAL_DELREF(*hash_entry);
+                                                                               
MAKE_STD_ZVAL(*hash_entry);
+                                                                       } else {
+                                                                               
zval_dtor(*hash_entry);
+                                                                       }
+                                                                       
ZVAL_STRINGL(*hash_entry, ret->val, ret->len, 0);
                                                                }
                                                        }
                                                }
@@ -3295,9 +3299,8 @@
                                        string.len = Z_STRLEN_PP(var);
                                        ret = mbfl_buffer_converter_feed_result(convd, 
&string, &result);
                                        if (ret != NULL) {
-                                               STR_FREE(Z_STRVAL_PP(var));
-                                               Z_STRVAL_PP(var) = (char *)ret->val;
-                                               Z_STRLEN_PP(var) = ret->len;
+                                               zval_dtor(*var);
+                                               ZVAL_STRINGL(*var, ret->val, ret->len, 
0);
                                        }
                                }
                        }
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.508 php-src/NEWS:1.1247.2.509
--- php-src/NEWS:1.1247.2.508   Wed Dec 17 16:10:23 2003
+++ php-src/NEWS        Thu Dec 18 04:52:51 2003
@@ -9,6 +9,8 @@
 - Added a warning when creating temp stream fails with ftp_(n)list(). (Sara)
 - Fixed header handler in NSAPI SAPI module (header->replace was ignored,
   send_default_content_type now sends value from php.ini). (Uwe Schindler)
+- Fixed bug #26639 (mb_convert_variables() clutters variables beyond the
+  references). (Moriyoshi)
 - Fixed bug #26635 (fixed look up for fonts in the current directory w/ZTS).
   (Ilia)
 - Fixed Bug #26625 (pg_convert sets NULL incorrectly for character data 

Index: php-src/ext/mbstring/tests/bug26639.phpt
+++ php-src/ext/mbstring/tests/bug26639.phpt
--TEST--
Bug #26639 (mb_convert_variables() clutters variables beyond the references)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
<?php
$a = "あいうえお";
$b = $a;
mb_convert_variables("EUC-JP", "Shift_JIS", $b);
debug_zval_dump($a);
debug_zval_dump($b);
unset($a);
unset($b);

$a = "あいうえお";
$b = &$a;
mb_convert_variables("EUC-JP", "Shift_JIS", $b);
debug_zval_dump($a);
debug_zval_dump($b);
unset($a);
unset($b);

$a = "あいうえお";
$b = array($a);
$c = $b;
mb_convert_variables("EUC-JP", "Shift_JIS", $c);
debug_zval_dump($b);
debug_zval_dump($c);
unset($a);
unset($b);
unset($c);

$a = "あいうえお";
$b = array(&$a);
$c = $b;
mb_convert_variables("euc-jp", "shift_jis", $c);
debug_zval_dump($b);
debug_zval_dump($c);
unset($a);
unset($b);
unset($c);

$a = "あいうえお";
$b = array($a);
$c = &$b;
mb_convert_variables("euc-jp", "shift_jis", $c);
debug_zval_dump($b);
debug_zval_dump($c);
unset($a);
unset($b);
unset($c);

$a = "あいうえお";
$b = array(&$a);
$c = &$b;
mb_convert_variables("euc-jp", "shift_jis", $c);
debug_zval_dump($b);
debug_zval_dump($c);
unset($a);
unset($b);
unset($c);
?>
--EXPECT--
string(10) "あいうえお" refcount(2)
string(10) "、「、、、ヲ、ィ、ェ" refcount(2)
string(10) "、「、、、ヲ、ィ、ェ" refcount(1)
string(10) "、「、、、ヲ、ィ、ェ" refcount(1)
array(1) refcount(2){
  [0]=>
  string(10) "あいうえお" refcount(2)
}
array(1) refcount(2){
  [0]=>
  string(10) "、「、、、ヲ、ィ、ェ" refcount(1)
}
array(1) refcount(2){
  [0]=>
  &string(10) "あいうえお" refcount(2)
}
array(1) refcount(2){
  [0]=>
  string(10) "、「、、、ヲ、ィ、ェ" refcount(1)
}
array(1) refcount(1){
  [0]=>
  string(10) "、「、、、ヲ、ィ、ェ" refcount(2)
}
array(1) refcount(1){
  [0]=>
  string(10) "、「、、、ヲ、ィ、ェ" refcount(2)
}
array(1) refcount(1){
  [0]=>
  string(10) "、「、、、ヲ、ィ、ェ" refcount(2)
}
array(1) refcount(1){
  [0]=>
  string(10) "、「、、、ヲ、ィ、ェ" refcount(2)
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to