Skip to content

Commit f89b0a2

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 67a349d + e8dda54 commit f89b0a2

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,12 @@ zend_string *accel_make_persistent_key(zend_string *str)
13451345
EXPECTED((parent_script = zend_get_executed_filename_ex()) != NULL)) {
13461346

13471347
parent_script_len = ZSTR_LEN(parent_script);
1348-
while ((--parent_script_len > 0) && !IS_SLASH(ZSTR_VAL(parent_script)[parent_script_len]));
1348+
while (parent_script_len > 0) {
1349+
--parent_script_len;
1350+
if (IS_SLASH(ZSTR_VAL(parent_script)[parent_script_len])) {
1351+
break;
1352+
}
1353+
}
13491354

13501355
if (UNEXPECTED((size_t)(key_length + parent_script_len + 1) >= ZCG_KEY_LEN)) {
13511356
return NULL;

ext/zend_test/tests/gh17899.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
GH-17899 (zend_test_compile_string with opcache crash on invalid script path)
3+
--EXTENSIONS--
4+
zend_test
5+
--INI--
6+
opcache.enable_cli=1
7+
--CREDITS--
8+
YuanchengJiang
9+
--FILE--
10+
<?php
11+
$source = '<?php
12+
require("sumfile.php");
13+
?>';
14+
try {zend_test_compile_string($source,$source,$c);} catch (Exception $e) { echo($e); }
15+
--EXPECTF--
16+
17+
Warning: Undefined variable $c in %s on line %d
18+
19+
Deprecated: zend_test_compile_string(): Passing null to parameter #3 ($position) of type int is deprecated in %s on line %d
20+
21+
Warning: require(sumfile.php): Failed to open stream: No such file or directory in <?php
22+
require("sumfile.php");
23+
?> on line %d
24+
25+
Fatal error: Uncaught Error: Failed opening required 'sumfile.php' (include_path='.%s') in <?php
26+
require("sumfile.php");
27+
?>:%d
28+
Stack trace:
29+
#0 %s(%d): zend_test_compile_string('<?php\nrequire("...', '<?php\nrequire("...', NULL)
30+
#1 {main}
31+
thrown in <?php
32+
require("sumfile.php");
33+
?> on line %d
34+

0 commit comments

Comments
 (0)