iliaa Wed Aug 25 20:26:20 2004 EDT
Modified files:
/php-src/ext/standard array.c
Log:
Fixed bug #29808 (array_count_values() breaks with numeric strings).
http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.272&r2=1.273&ty=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.272 php-src/ext/standard/array.c:1.273
--- php-src/ext/standard/array.c:1.272 Thu Aug 12 02:17:42 2004
+++ php-src/ext/standard/array.c Wed Aug 25 20:26:19 2004
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.272 2004/08/12 06:17:42 andi Exp $ */
+/* $Id: array.c,v 1.273 2004/08/26 00:26:19 iliaa Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -2415,6 +2415,7 @@
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) {
@@ -2427,6 +2428,13 @@
Z_LVAL_PP(tmp)++;
}
} 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;
+ }
+
if (zend_hash_find(Z_ARRVAL_P(return_value),
Z_STRVAL_PP(entry), Z_STRLEN_PP(entry)+1, (void**)&tmp) == FAILURE) {
zval *data;
MAKE_STD_ZVAL(data);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php