[php-src] PR #12613: Fix unspecified behaviour in zend_alloc in heap->limit computation
| From: | nielsdos | Date: | Sun, 05 Nov 2023 00:43:42 +0000 |
| Subject: | [php-src] PR #12613: Fix unspecified behaviour in zend_alloc in heap->limit computation | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-24112@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/12613
Author: nielsdos
Right-shifting a negative number is unspecified (i.e. implementation-defined) behaviour [1]. If we
take a look at the generated assembly [2], we see that the wrong value is computed. Fix it by using
Z_UL instead of Z_L.
While we're at it, just change every occurrence of this pattern to use Z_UL instead of casting.
[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
§6.5.7.5
[2] https://godbolt.org/z/4Y1qKKjsh