Skip to content

Commit 0e882f1

Browse files
committed
Constant evaluation of ini_get() for some safe cases
1 parent 9e36a74 commit 0e882f1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,24 @@ static inline int ct_eval_func_call(
545545
}
546546
ZVAL_STR(result, str);
547547
return SUCCESS;
548+
} else if (zend_string_equals_literal(name, "ini_get")) {
549+
zend_ini_entry *ini_entry;
550+
551+
if (num_args != 1 || Z_TYPE_P(args[0]) != IS_STRING) {
552+
return FAILURE;
553+
}
554+
555+
ini_entry = zend_hash_find_ptr(EG(ini_directives), Z_STR_P(args[0]));
556+
if (!ini_entry) {
557+
ZVAL_FALSE(result);
558+
} else if (ini_entry->modifiable != ZEND_INI_SYSTEM) {
559+
return FAILURE;
560+
} else if (ini_entry->value) {
561+
ZVAL_STR_COPY(result, ini_entry->value);
562+
} else {
563+
ZVAL_EMPTY_STRING(result);
564+
}
565+
return SUCCESS;
548566
} else {
549567
uint32_t i;
550568
zend_execute_data *execute_data;
@@ -580,9 +598,6 @@ static inline int ct_eval_func_call(
580598
|| (num_args == 2 && Z_TYPE_P(args[0]) == IS_ARRAY && Z_TYPE_P(args[1]) == IS_STRING))) {
581599
/* pass */
582600
} else {
583-
#if 0
584-
fprintf(stderr, "constant ICALL to %s()\n", ZSTR_VAL(name));
585-
#endif
586601
return FAILURE;
587602
}
588603

0 commit comments

Comments
 (0)