Skip to content

Commit e7f69f0

Browse files
committed
Prevent compile-time evaluation of implode() with arguments causing run-time warnings
1 parent 0e882f1 commit e7f69f0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,21 @@ static inline int ct_eval_func_call(
596596
&& ((num_args == 1 && Z_TYPE_P(args[0]) == IS_ARRAY)
597597
|| (num_args == 2 && Z_TYPE_P(args[0]) == IS_STRING && Z_TYPE_P(args[1]) == IS_ARRAY)
598598
|| (num_args == 2 && Z_TYPE_P(args[0]) == IS_ARRAY && Z_TYPE_P(args[1]) == IS_STRING))) {
599+
zval *entry;
600+
601+
if (Z_TYPE_P(args[0]) == IS_ARRAY) {
602+
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args[0]), entry) {
603+
if (Z_TYPE_P(entry) > IS_STRING) {
604+
return FAILURE;
605+
}
606+
} ZEND_HASH_FOREACH_END();
607+
} else {
608+
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args[1]), entry) {
609+
if (Z_TYPE_P(entry) > IS_STRING) {
610+
return FAILURE;
611+
}
612+
} ZEND_HASH_FOREACH_END();
613+
}
599614
/* pass */
600615
} else {
601616
return FAILURE;

0 commit comments

Comments
 (0)