]> granicus.if.org Git - php/commitdiff
Fixed parse_ini_file
authorXinchen Hui <laruence@gmail.com>
Sun, 9 Mar 2014 03:35:20 +0000 (11:35 +0800)
committerXinchen Hui <laruence@gmail.com>
Sun, 9 Mar 2014 03:35:20 +0000 (11:35 +0800)
Zend/zend_ini_parser.y
ext/standard/basic_functions.c

index 268f21bb86f1657203ff3963fe13010b4ecf2360..e9bebf189f46fb440af305feef14ca48b749c95c 100644 (file)
@@ -136,7 +136,7 @@ static void zend_ini_get_var(zval *result, zval *name TSRMLS_DC)
        char *envvar;
 
        /* Fetch configuration option value */
-       if (zend_get_configuration_directive(Z_STRVAL_P(name), Z_STRLEN_P(name)+1, &curval) == SUCCESS) {
+       if (zend_get_configuration_directive(Z_STRVAL_P(name), Z_STRLEN_P(name), &curval) == SUCCESS) {
                ZVAL_PSTRINGL(result, Z_STRVAL(curval), Z_STRLEN(curval));
        /* ..or if not found, try ENV */
        } else if ((envvar = zend_getenv(Z_STRVAL_P(name), Z_STRLEN_P(name) TSRMLS_CC)) != NULL ||
index 499aa82229386bed08b84803bfc56eddd118a8c4..d666c025bb35082531d48cb8cab954cc42ce340a 100644 (file)
@@ -5906,33 +5906,27 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
                                ulong key = (ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
                                if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) {
                                        array_init(&hash);
-
-                                       zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash);
-                               } else {
-                                       ZVAL_COPY_VALUE(&hash, find_hash);
-                               }
+                                       find_hash = zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash);
+                               } 
                        } else {
                                if ((find_hash = zend_hash_find(Z_ARRVAL_P(arr), Z_STR_P(arg1))) == NULL) {
                                        array_init(&hash);
-
-                                       zend_hash_update(Z_ARRVAL_P(arr), Z_STR_P(arg1), &hash);
-                               } else {
-                                       ZVAL_COPY_VALUE(&hash, find_hash);
-                               }
+                                       find_hash = zend_hash_update(Z_ARRVAL_P(arr), Z_STR_P(arg1), &hash);
+                               } 
                        }
 
-                       if (Z_TYPE(hash) != IS_ARRAY) {
-                               zval_dtor(&hash);
-                               array_init(&hash);
+                       if (Z_TYPE_P(find_hash) != IS_ARRAY) {
+                               zval_dtor(find_hash);
+                               array_init(find_hash);
                        }
 
                        ZVAL_DUP(&element, arg2);
 
                        if (arg3 && Z_STRLEN_P(arg3) > 0) {
 //???
-                               add_assoc_zval_ex(&hash, Z_STRVAL_P(arg3), Z_STRLEN_P(arg3), &element);
+                               add_assoc_zval_ex(find_hash, Z_STRVAL_P(arg3), Z_STRLEN_P(arg3), &element);
                        } else {
-                               add_next_index_zval(&hash, &element);
+                               add_next_index_zval(find_hash, &element);
                        }
                }
                break;