Skip to content

Commit 0d022dd

Browse files
committed
Fix #80220: imap_mail_compose() may leak memory
Unless `topbod` is of `TYPEMULTIPART`, `mail_free_body()` does not free the `nested.part`; while we could do this ourselves, instead we just ignore additional bodies in this case, i.e. we don't attach them in the first place. Closes GH-6321.
1 parent 3c4dd73 commit 0d022dd

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PHP NEWS
1212
- IMAP:
1313
. Fixed bug #80213 (imap_mail_compose() segfaults on certain $bodies). (cmb)
1414
. Fixed bug #80215 (imap_mail_compose() may modify by-val parameters). (cmb)
15+
. Fixed bug #80220 (imap_mail_compose() may leak memory). (cmb)
1516

1617
- MySQLnd:
1718
. Fixed bug #80115 (mysqlnd.debug doesn't recognize absolute paths with

ext/imap/php_imap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3714,7 +3714,7 @@ PHP_FUNCTION(imap_mail_compose)
37143714
convert_to_string_ex(pvalue);
37153715
bod->md5 = cpystr(Z_STRVAL_P(pvalue));
37163716
}
3717-
} else if (Z_TYPE_P(data) == IS_ARRAY) {
3717+
} else if (Z_TYPE_P(data) == IS_ARRAY && topbod->type == TYPEMULTIPART) {
37183718
short type = -1;
37193719
SEPARATE_ARRAY(data);
37203720
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "type", sizeof("type") - 1)) != NULL) {

0 commit comments

Comments
 (0)