Commit a9eeac2
committed
Fix GH-17399: iconv memory leak with large line-length
Move the buf allocation in _php_iconv_mime_encode() before the
iconv_open() calls. When max_line_len is excessively large (e.g.
PHP_INT_MAX), safe_emalloc triggers an OOM bailout that skips
cleanup, leaking the iconv handles allocated via system malloc.
By allocating buf first, a bailout happens before any iconv
handles exist.
Closes GH-173991 parent 5e45c17 commit a9eeac2
2 files changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
942 | 942 | | |
943 | 943 | | |
944 | 944 | | |
| 945 | + | |
| 946 | + | |
945 | 947 | | |
946 | 948 | | |
947 | 949 | | |
| |||
962 | 964 | | |
963 | 965 | | |
964 | 966 | | |
965 | | - | |
966 | | - | |
967 | 967 | | |
968 | 968 | | |
969 | 969 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments