diff options
author | Antony Dovgal <tony2001@php.net> | 2005-10-04 20:47:48 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2005-10-04 20:47:48 +0000 |
commit | f3e70f5b8cca10e732cc9160db7b9919534b8d32 (patch) | |
tree | 925a26c3cd9a7fd10111e7ea819c32e3f087913c | |
parent | 17bc1d09e841ac8198cccf03430689780fd40f83 (diff) | |
download | php-git-f3e70f5b8cca10e732cc9160db7b9919534b8d32.tar.gz |
fix #34723 (array_count_values() strips leading zeroes)
-rw-r--r-- | ext/standard/array.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index db228071c4..a5ec285b85 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2726,9 +2726,10 @@ PHP_FUNCTION(array_count_values) } else if (Z_TYPE_PP(entry) == IS_STRING || Z_TYPE_PP(entry) == IS_BINARY || Z_TYPE_PP(entry) == IS_UNICODE) { - /* make sure our array does not end up with numeric string keys */ - if ((Z_TYPE_PP(entry) == IS_STRING && is_numeric_string(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, NULL, 0) == IS_LONG) || - (Z_TYPE_PP(entry) == IS_UNICODE && is_numeric_unicode(Z_USTRVAL_PP(entry), Z_USTRLEN_PP(entry), NULL, NULL, 0) == IS_LONG)) { + /* make sure our array does not end up with numeric string keys + * but don't touch those strings that start with 0 */ + if ((Z_TYPE_PP(entry) == IS_STRING && !(Z_STRLEN_PP(entry) > 1 && Z_STRVAL_PP(entry)[0] == '0') && is_numeric_string(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, NULL, 0) == IS_LONG) || + (Z_TYPE_PP(entry) == IS_UNICODE && zend_cmp_unicode_and_literal(Z_USTRVAL_PP(entry), 1, "0", sizeof("0")-1) && is_numeric_unicode(Z_USTRVAL_PP(entry), Z_USTRLEN_PP(entry), NULL, NULL, 0) == IS_LONG)) { zval tmp_entry; tmp_entry = **entry; |