Skip to content

Commit 81dfb44

Browse files
authored
Fix GH-24523: UAF in zend_test_compile_to_ast() on parse error (#24524)
1 parent 292db49 commit 81dfb44

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎ext/zend_test/test.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,9 @@ static PHP_FUNCTION(zend_test_compile_to_ast)
19761976

19771977
zend_arena *ast_arena;
19781978
zend_ast *ast = zend_compile_string_to_ast(str, &ast_arena, ZSTR_EMPTY_ALLOC());
1979+
if (!ast) {
1980+
RETURN_THROWS();
1981+
}
19791982

19801983
zend_string *result = zend_ast_export("", ast, "");
19811984

‎ext/zend_test/tests/gh24523.phpt‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
GH-24523 (UAF in zend_test_compile_to_ast() on parse error)
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
8+
try {
9+
zend_test_compile_to_ast("<?php (");
10+
} catch (ParseError $e) {
11+
echo $e->getMessage(), "\n";
12+
}
13+
14+
?>
15+
--EXPECT--
16+
Unclosed '('

0 commit comments

Comments
 (0)