[php-src] PR #21541: Fix GH-17399: iconv memory leak with large line-length
| From: | iliaal | Date: | Thu, 26 Mar 2026 19:00:39 +0000 |
| Subject: | [php-src] PR #21541: Fix GH-17399: iconv memory leak with large line-length | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35378@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21541
Author: iliaal
## Summary
_php_iconv_mime_encode() opens two iconv_t handles via system
malloc, then calls safe_emalloc(1, max_line_len, 5). When
max_line_len is PHP_INT_MAX, the allocation triggers an OOM bailout that
skips iconv_close() cleanup, leaking both handles.
Fix: move safe_emalloc before both iconv_open() calls. If it bails out, no
handles exist to leak.
@cmb69 suggested this approach in the issue thread.
Fixes #17399