Skip to content

Commit 3ae5252

Browse files
committed
Fix memory leak in lexer token string allocation
The emit_token_with_str label was unconditionally allocating strings via zend_copy_value, but these strings were only consumed when in parser mode (i.e., when elem != NULL). When not in parser mode, the allocated strings were never freed, causing memory leaks detected by LeakSanitizer.
1 parent 5bc45dc commit 3ae5252

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Zend/zend_language_scanner.l

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3204,7 +3204,9 @@ nowdoc_scan_done:
32043204
*/
32053205
32063206
emit_token_with_str:
3207-
zend_copy_value(zendlval, (yytext + offset), (yyleng - offset));
3207+
if (PARSER_MODE()) {
3208+
zend_copy_value(zendlval, (yytext + offset), (yyleng - offset));
3209+
}
32083210
32093211
emit_token_with_val:
32103212
if (PARSER_MODE()) {

0 commit comments

Comments
 (0)