Skip to content

mbstring: save the write offset before reallocating - #25570

Open
realFlowControl wants to merge 1 commit into
php:masterfrom
realFlowControl:florian/mbstring-save-write-offset
Open

realFlowControl wants to merge 1 commit into
php:masterfrom
realFlowControl:florian/mbstring-save-write-offset

Conversation

@realFlowControl

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant