Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  Fix GH-16630: UAF in lexer with encoding translation and heredocs
This commit is contained in:
Niels Dossche 2024-11-18 19:59:08 +01:00
commit e00d684420
No known key found for this signature in database
GPG Key ID: B8A8AD166DF0E2E5
2 changed files with 20 additions and 1 deletions

19
Zend/tests/gh16630.phpt Normal file
View File

@ -0,0 +1,19 @@
--TEST--
GH-16630 (UAF in lexer with encoding translation and heredocs)
--EXTENSIONS--
mbstring
--INI--
zend.multibyte=On
zend.script_encoding=ISO-8859-1
internal_encoding=EUC-JP
--FILE--
<?php
$data3 = <<<CODE
heredoc
text
CODE;
echo $data3;
?>
--EXPECT--
heredoc
text

View File

@ -275,7 +275,7 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state)
CG(zend_lineno) = lex_state->lineno;
zend_restore_compiled_filename(lex_state->filename);
if (SCNG(script_filtered)) {
if (SCNG(script_filtered) && SCNG(script_filtered) != lex_state->script_filtered) {
efree(SCNG(script_filtered));
SCNG(script_filtered) = NULL;
}