Skip to content

Conversation

@nikic
Copy link
Member

@nikic nikic commented Mar 31, 2012

This fixes bug #60097 (https://bugs.php.net/bug.php?id=60097).

Before, two global variables CG(heredoc) and CG(heredoc_len) were used to
track the current heredoc label. In order to support nested heredoc
strings the previous heredoc label was assigned as the token value of
T_START_HEREDOC and the language_parser.y assigned that to CG(heredoc).

This created a dependency of the lexer on the parser. Thus the
token_get_all() function, which accesses the lexer directly without
also running the parser, was not able to tokenize nested heredoc strings
(and leaked memory). Same applies for the source-code highlighting
functions.

The new approach is to maintain a heredoc_label_stack in the lexer, which
contains all active heredoc labels.

As it is no longer required, T_START_HEREDOC and T_END_HEREDOC now don't
carry a token value anymore.

In order to make the work with zend_ptr_stack in this context more
convenient I added a new function zend_ptr_stack_top(), which retrieves the
top element of the stack (similar to zend_stack_top()).

This fixes bug #60097.

Before two global variables CG(heredoc) and CG(heredoc_len) were used to
track the current heredoc label. In order to support nested heredoc
strings the *previous* heredoc label was assigned as the token value of
T_START_HEREDOC and the language_parser.y assigned that to CG(heredoc).

This created a dependency of the lexer on the parser. Thus the
token_get_all() function, which accesses the lexer directly without
also running the parser, was not able to tokenize nested heredoc strings
(and leaked memory). Same applies for the source-code highlighting
functions.

The new approach is to maintain a heredoc_label_stack in the lexer, which
contains all active heredoc labels.

As it is no longer required, T_START_HEREDOC and T_END_HEREDOC now don't
carry a token value anymore.

In order to make the work with zend_ptr_stack in this context more
convenient I added a new function zend_ptr_stack_top(), which retrieves the
top element of the stack (similar to zend_stack_top()).
@php-pulls php-pulls merged commit 4cf90e0 into php:master Aug 20, 2012
php-pulls pushed a commit that referenced this pull request Dec 20, 2013
@rentalhost
Copy link

+1

hikari-no-yume added a commit to hikari-no-yume/php-src that referenced this pull request Jan 9, 2015
hikari-no-yume added a commit to hikari-no-yume/php-src that referenced this pull request Jan 12, 2015
hikari-no-yume added a commit to hikari-no-yume/php-src that referenced this pull request Jan 15, 2015
hikari-no-yume added a commit to hikari-no-yume/php-src that referenced this pull request Jan 17, 2015
hikari-no-yume added a commit to hikari-no-yume/php-src that referenced this pull request Jan 17, 2015
hikari-no-yume added a commit to hikari-no-yume/php-src that referenced this pull request Jan 17, 2015
EdmondDantes added a commit to true-async/php-src that referenced this pull request Jul 14, 2025
EdmondDantes added a commit to true-async/php-src that referenced this pull request Jul 14, 2025
EdmondDantes added a commit to true-async/php-src that referenced this pull request Jul 14, 2025
…mpatible syntax

         - Change `data[]` to `data[1]` in zend_async_waker_trigger_s structure
         - Adjust memory allocation calculations to account for included array element
         - Ensures compatibility with MSVC compiler while maintaining functionality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants