Skip to content

Fix memory leaks in mailparse_uudecode_all#67

Closed
iliaal wants to merge 1 commit into
masterfrom
fix/uudecode-all-leaks
Closed

Fix memory leaks in mailparse_uudecode_all#67
iliaal wants to merge 1 commit into
masterfrom
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.

@iliaal

iliaal commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #72, reopened from the fork (iliaal/pecl-mail-mailparse). Branch should not have been pushed to php/ directly.

@iliaal iliaal closed this Jun 19, 2026
@iliaal iliaal deleted the fix/uudecode-all-leaks branch June 19, 2026 13:19
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