Skip to content

Commit 21d9931

Browse files
committed
Fix user ini parsing under RC_DEBUG
Suppress checking during the actual parsing, but make sure to duplicate strings on activate. The parsing result may be shared across requests, but activation should work on per-request strings.
1 parent 1da5df8 commit 21d9931

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

main/php_ini.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,17 @@ PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename
782782
/* Reset active ini section */
783783
RESET_ACTIVE_INI_HASH();
784784

785+
#if ZEND_RC_DEBUG
786+
/* User inis are parsed during SAPI activate (part of the request),
787+
* but persistently allocated to allow caching. This is fine as long as
788+
* strings are duplicated in php_ini_activate_config(). */
789+
bool orig_rc_debug = zend_rc_debug;
790+
zend_rc_debug = false;
791+
#endif
785792
ret = zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, target_hash);
793+
#if ZEND_RC_DEBUG
794+
zend_rc_debug = orig_rc_debug;
795+
#endif
786796
if (ret == SUCCESS) {
787797
/* FIXME: Add parsed file to the list of user files read? */
788798
}
@@ -803,7 +813,9 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int
803813

804814
/* Walk through config hash and alter matching ini entries using the values found in the hash */
805815
ZEND_HASH_FOREACH_STR_KEY_VAL(source_hash, str, data) {
806-
zend_alter_ini_entry_ex(str, Z_STR_P(data), modify_type, stage, 0);
816+
zend_string *data_str = zend_string_dup(Z_STR_P(data), 0);
817+
zend_alter_ini_entry_ex(str, data_str, modify_type, stage, 0);
818+
zend_string_release(data_str);
807819
} ZEND_HASH_FOREACH_END();
808820
}
809821
/* }}} */

0 commit comments

Comments
 (0)