tony2001                Mon Jan  5 09:14:58 2009 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/mbstring       mbstring.c 
  Log:
  fix memleaks correctly and make valgrind happy
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.224.2.22.2.25.2.43&r2=1.224.2.22.2.25.2.44&diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.224.2.22.2.25.2.43 
php-src/ext/mbstring/mbstring.c:1.224.2.22.2.25.2.44
--- php-src/ext/mbstring/mbstring.c:1.224.2.22.2.25.2.43        Wed Dec 31 
11:15:38 2008
+++ php-src/ext/mbstring/mbstring.c     Mon Jan  5 09:14:58 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mbstring.c,v 1.224.2.22.2.25.2.43 2008/12/31 11:15:38 sebastian Exp $ 
*/
+/* $Id: mbstring.c,v 1.224.2.22.2.25.2.44 2009/01/05 09:14:58 tony2001 Exp $ */
 
 /*
  * PHP 4 Multibyte String module "mbstring"
@@ -1883,12 +1883,12 @@
 PHP_FUNCTION(mb_detect_order)
 {
        size_t argc = ZEND_NUM_ARGS();
-       zval *arg1;
+       zval **arg1;
        int n, size;
        enum mbfl_no_encoding *list, *entry;
        char *name;
 
-       if (zend_parse_parameters(argc TSRMLS_CC, "|z", &arg1) == FAILURE) {
+       if (zend_parse_parameters(argc TSRMLS_CC, "|Z", &arg1) == FAILURE) {
                return;
        }
 
@@ -1907,9 +1907,9 @@
        } else {
                list = NULL;
                size = 0;
-               switch (Z_TYPE_P(arg1)) {
+               switch (Z_TYPE_PP(arg1)) {
                case IS_ARRAY:
-                       if (!php_mb_parse_encoding_array(arg1, &list, &size, 0 
TSRMLS_CC)) {
+                       if (!php_mb_parse_encoding_array(*arg1, &list, &size, 0 
TSRMLS_CC)) {
                                if (list) {
                                        efree(list);
                                }
@@ -1917,15 +1917,13 @@
                        }
                        break;
                default:
-                       convert_to_string_ex(&arg1);
-                       if (!php_mb_parse_encoding_list(Z_STRVAL_P(arg1), 
Z_STRLEN_P(arg1), &list, &size, 0 TSRMLS_CC)) {
+                       convert_to_string_ex(arg1);
+                       if (!php_mb_parse_encoding_list(Z_STRVAL_PP(arg1), 
Z_STRLEN_PP(arg1), &list, &size, 0 TSRMLS_CC)) {
                                if (list) {
                                        efree(list);
                                }
-                               zval_ptr_dtor(&arg1);
                                RETURN_FALSE;
                        }
-                       zval_ptr_dtor(&arg1);
                        break;
                }
 
@@ -1947,9 +1945,9 @@
    Sets the current substitute_character or returns the current 
substitute_character */
 PHP_FUNCTION(mb_substitute_character)
 {
-       zval *arg1;
+       zval **arg1;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &arg1) == 
FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Z", &arg1) == 
FAILURE) {
                return;
        }
 
@@ -1966,36 +1964,32 @@
        } else {
                RETVAL_TRUE;
 
-               switch (Z_TYPE_P(arg1)) {
+               switch (Z_TYPE_PP(arg1)) {
                case IS_STRING:
-                       if (strncasecmp("none", Z_STRVAL_P(arg1), 
Z_STRLEN_P(arg1)) == 0) {
+                       if (strncasecmp("none", Z_STRVAL_PP(arg1), 
Z_STRLEN_PP(arg1)) == 0) {
                                MBSTRG(current_filter_illegal_mode) = 
MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE;
-                       } else if (strncasecmp("long", Z_STRVAL_P(arg1), 
Z_STRLEN_P(arg1)) == 0) {
+                       } else if (strncasecmp("long", Z_STRVAL_PP(arg1), 
Z_STRLEN_PP(arg1)) == 0) {
                                MBSTRG(current_filter_illegal_mode) = 
MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG;
-                       } else if (strncasecmp("entity", Z_STRVAL_P(arg1), 
Z_STRLEN_P(arg1)) == 0) {
+                       } else if (strncasecmp("entity", Z_STRVAL_PP(arg1), 
Z_STRLEN_PP(arg1)) == 0) {
                                MBSTRG(current_filter_illegal_mode) = 
MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY;
                        } else {
-                               convert_to_long_ex(&arg1);
+                               convert_to_long_ex(arg1);
 
-                               if (Z_LVAL_P(arg1) < 0xffff && Z_LVAL_P(arg1) > 
0x0) {
+                               if (Z_LVAL_PP(arg1) < 0xffff && Z_LVAL_PP(arg1) 
> 0x0) {
                                        MBSTRG(current_filter_illegal_mode) = 
MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
-                                       
MBSTRG(current_filter_illegal_substchar) = Z_LVAL_P(arg1);
-                                       zval_ptr_dtor(&arg1);
+                                       
MBSTRG(current_filter_illegal_substchar) = Z_LVAL_PP(arg1);
                                } else {
-                                       zval_ptr_dtor(&arg1);
                                        php_error_docref(NULL TSRMLS_CC, 
E_WARNING, "Unknown character.");
                                        RETURN_FALSE;
                                }
                        }
                        break;
                default:
-                       convert_to_long_ex(&arg1);
-                       if (Z_LVAL_P(arg1) < 0xffff && Z_LVAL_P(arg1) > 0x0) {
+                       convert_to_long_ex(arg1);
+                       if (Z_LVAL_PP(arg1) < 0xffff && Z_LVAL_PP(arg1) > 0x0) {
                                MBSTRG(current_filter_illegal_mode) = 
MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
-                               MBSTRG(current_filter_illegal_substchar) = 
Z_LVAL_P(arg1);
-                               zval_ptr_dtor(&arg1);
+                               MBSTRG(current_filter_illegal_substchar) = 
Z_LVAL_PP(arg1);
                        } else {
-                               zval_ptr_dtor(&arg1);
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Unknown character.");
                                RETURN_FALSE;
                        }



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

Reply via email to