Repository navigation
Conversation
DCE rewrites a dead instruction whose operand still needs freeing into a FREE, but kept the instruction's extended_value. After (float) and (array) casts and empty() it has bit 0 set, which ZEND_HANDLE_EXCEPTION reads as ZEND_FREE_ON_RETURN: when a destructor run by that FREE throws, the throw point moves by the FREE's op2, which is (uint32_t)-1, and cleanup_live_vars() frees the operand a second time. Closes phpGH-25836
The DB-Lib error and message handlers estrdup() server and library text into the connection's pdo_dblib_err. For a persistent connection, errors raised through PDO::exec() and the transaction and lastInsertId() calls stay there until the next statement execute, so a request that ends after such an error leaves pointers into the reset request heap. The next request efree()s them from the message or error handler or the cursor closer, and module shutdown does from the handle closer. Free them from persistent_shutdown once the last PDO object using the connection is released. Closes phpGH-25159
…#25719) Dereference the options element of the context parameters before checking its type, so stream_context_create() and stream_context_set_params() accept references to valid options arrays. References to other types still raise a TypeError. Co-authored-by: Gina Peter Banyard <girgias@php.net> Closes php#25719
…down. Objects outliving RSHUTDOWN dropped an empty archive at refcount 0 through the already destroyed fname map, while another object still held it. The archive is now left to its last holder. Fix phpGH-25722 Close phpGH-25728
socket_addrinfo_lookup(), socket_bind(), socket_connect(), socket_sendto() and socket_sendmsg() would otherwise resolve only the part before the NUL byte. Closes phpGH-25774
When zend_string_safe_falloc() fails under memory_limit, php_str_to_str_i_ex() returned NULL without releasing the lowercased needle. Closes phpGH-25848
zend_multibyte_yyinput_again() re-converts the whole script with the new input filter, but kept the cursor at the byte offset it had in the old filtered buffer. When the code before declare(encoding=...) converts to a different length under the new encoding, scanning resumed before or after the end of the declare, which caused parse errors, silently skipped code, or reads past the end of the new buffer. Map the cursor back to the source offset through the old filter and forward through the new one. The backward search, shared with zend_get_scanned_file_offset(), becomes a bisection for the shortest source prefix whose conversion starts with the scanned bytes: it needs O(log n) conversions instead of one per byte, and it ends on a character boundary even when a truncated character converts to a substitute of a different length.
iliaal
force-pushed
the
fix/zend-multibyte-yyinput-again-offset
branch
from
November 28, 2026 15:26
d7a8a6a to
6995062
Compare
Owner
Author
|
Promoted upstream as php/php-src phpGH-25875. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With zend.multibyte on,
declare(encoding=...)re-converts the whole script with the new encoding but kept the scanner cursor at its byte offset in the old converted buffer. When the code before the declare converts to a different length, scanning resumes at the wrong place: valid scripts fail to parse or skip bytes, and a shorter conversion such as UTF-32 puts the cursor past the end of the buffer, whichtoken_get_all(..., TOKEN_PARSE)turns into a heap over-read.The cursor is now mapped back to a source offset through the old filter and forward through the new one. The backward search it shares with
zend_get_scanned_file_offset()is now a bisection for the shortest source prefix whose conversion starts with the scanned bytes, so it terminates when a truncated UTF-16 unit converts to a multi-byte substitute and costs a logarithmic number of conversions instead of one per byte.Companion to #362, which pads the converted buffer. Found while validating #362; an independent review fuzzed 1,273 scripts across encodings and substitute settings with no regressions against PHP-8.4. multibyte_encoding_010.phpt fails before and passes after under ASAN.