Skip to content

Commit

Permalink
Merge branch 'PHP-8.4'
Browse files Browse the repository at this point in the history
* PHP-8.4:
  Fix phpGH-16630: UAF in lexer with encoding translation and heredocs
  • Loading branch information
nielsdos committed Nov 18, 2024
2 parents 4b517a9 + e00d684 commit dd4fc9a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Zend/tests/gh16630.phpt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Zend/zend_language_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit dd4fc9a

Please sign in to comment.