[php-src] PR #25570: mbstring: save the write offset before reallocating
| From: | realFlowControl | Date: | Wed, 18 Nov 2026 22:16:56 +0000 |
| Subject: | [php-src] PR #25570: mbstring: save the write offset before reallocating | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40793@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25570
Author: realFlowControl
When
mb_convert_buf_ensure() grows the conversion buffer, it calculates the write
offset by subtracting two pointers into the old buffer after calling safe_ferealloc().
If the allocation moves, those pointers are no longer valid. Subtracting them is undefined behavior
even though neither is dereferenced.
This PR saves the offset before reallocating, then add it to the new buffer’s base address.