tony2001 Tue Apr 12 10:00:55 2005 EDT Modified files: /php-src/ext/standard array.c Log: fix #30833 (array_count_values modifying input array) http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.296&r2=1.297&ty=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.296 php-src/ext/standard/array.c:1.297 --- php-src/ext/standard/array.c:1.296 Mon Mar 21 20:45:17 2005 +++ php-src/ext/standard/array.c Tue Apr 12 10:00:54 2005 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.296 2005/03/22 01:45:17 iliaa Exp $ */ +/* $Id: array.c,v 1.297 2005/04/12 14:00:54 tony2001 Exp $ */ #include "php.h" #include "php_ini.h" @@ -2466,7 +2466,6 @@ zend_hash_internal_pointer_reset_ex(myht, &pos); while (zend_hash_get_current_data_ex(myht, (void **)&entry, &pos) == SUCCESS) { if (Z_TYPE_PP(entry) == IS_LONG) { -int_key: if (zend_hash_index_find(Z_ARRVAL_P(return_value), Z_LVAL_PP(entry), (void**)&tmp) == FAILURE) { @@ -2481,9 +2480,28 @@ } else if (Z_TYPE_PP(entry) == IS_STRING) { /* make sure our array does not end up with numeric string keys */ if (is_numeric_string(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, NULL, 0) == IS_LONG) { - SEPARATE_ZVAL(entry); - convert_to_long_ex(entry); - goto int_key; + zval tmp_entry; + + tmp_entry = **entry; + zval_copy_ctor(&tmp_entry); + + convert_to_long(&tmp_entry); + + if (zend_hash_index_find(Z_ARRVAL_P(return_value), + Z_LVAL(tmp_entry), + (void**)&tmp) == FAILURE) { + zval *data; + MAKE_STD_ZVAL(data); + Z_TYPE_P(data) = IS_LONG; + Z_LVAL_P(data) = 1; + zend_hash_index_update(Z_ARRVAL_P(return_value), Z_LVAL(tmp_entry), &data, sizeof(data), NULL); + } else { + Z_LVAL_PP(tmp)++; + } + + zval_dtor(&tmp_entry); + zend_hash_move_forward_ex(myht, &pos); + continue; } if (zend_hash_find(Z_ARRVAL_P(return_value), Z_STRVAL_PP(entry), Z_STRLEN_PP(entry)+1, (void**)&tmp) == FAILURE) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php