Skip to content

Fix memory leaks in mailparse_uudecode_all#72

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/uudecode-all-leaks
Open

Fix memory leaks in mailparse_uudecode_all#72
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/uudecode-all-leaks

Conversation

@iliaal

@iliaal iliaal commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What

mailparse_uudecode_all() leaks in two cases:

  1. Input with no begin line never releases the initial temp-file path zend_string (allocated up front, released only inside the first-begin branch). Any non-uuencoded stream triggers it.
  2. If per-part temp-file creation fails, the half-built item array zval is never inserted into the result nor freed.

Fix

Track the initial path in its own variable and NULL it once released, then release it at the tail if no begin line was seen. Give the per-part stream its own partpath variable so the initial path is never clobbered. Free the item on the temp-file-failure branch, and discard the partial result array if a begin was seen but every part failed.

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.

1 participant