iliaa Sun Nov 9 23:12:39 2003 EDT Modified files: /php-src/ext/standard basic_functions.c Log: Fixed bug #26176 (Fixed handling of numeric keys in INI files). Index: php-src/ext/standard/basic_functions.c diff -u php-src/ext/standard/basic_functions.c:1.637 php-src/ext/standard/basic_functions.c:1.638 --- php-src/ext/standard/basic_functions.c:1.637 Wed Oct 29 19:49:33 2003 +++ php-src/ext/standard/basic_functions.c Sun Nov 9 23:12:38 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.637 2003/10/30 00:49:33 iliaa Exp $ */ +/* $Id: basic_functions.c,v 1.638 2003/11/10 04:12:38 iliaa Exp $ */ #include "php.h" #include "php_streams.h" @@ -2877,7 +2877,12 @@ *element = *arg2; zval_copy_ctor(element); INIT_PZVAL(element); - zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); + if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) { + zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); + } else { + ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)); + zend_hash_index_update(Z_ARRVAL_P(arr), key, &element, sizeof(zval *), NULL); + } break; case ZEND_INI_PARSER_POP_ENTRY: @@ -2889,14 +2894,27 @@ break; } - if (zend_hash_find(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, (void **) &find_hash) == FAILURE) { - ALLOC_ZVAL(hash); - INIT_PZVAL(hash); - array_init(hash); - - zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &hash, sizeof(zval *), NULL); + if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) { + if (zend_hash_find(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, (void **) &find_hash) == FAILURE) { + ALLOC_ZVAL(hash); + INIT_PZVAL(hash); + array_init(hash); + + zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &hash, sizeof(zval *), NULL); + } else { + hash = *find_hash; + } } else { - hash = *find_hash; + ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)); + if (zend_hash_index_find(Z_ARRVAL_P(arr), key, (void **) &find_hash) == FAILURE) { + ALLOC_ZVAL(hash); + INIT_PZVAL(hash); + array_init(hash); + + zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash, sizeof(zval *), NULL); + } else { + hash = *find_hash; + } } ALLOC_ZVAL(element); @@ -2919,11 +2937,12 @@ if (callback_type == ZEND_INI_PARSER_SECTION) { MAKE_STD_ZVAL(BG(active_ini_file_section)); array_init(BG(active_ini_file_section)); - zend_hash_update( Z_ARRVAL_P(arr), - Z_STRVAL_P(arg1), - Z_STRLEN_P(arg1)+1, - &BG(active_ini_file_section), - sizeof(zval *), NULL); + if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) { + zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &BG(active_ini_file_section), sizeof(zval *), NULL); + } else { + ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)); + zend_hash_index_update(Z_ARRVAL_P(arr), key, &BG(active_ini_file_section), sizeof(zval *), NULL); + } } else if (arg2) { zval *active_arr;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php