Skip to content

Commit 4a469c7

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #80223: imap_mail_compose() leaks envelope on malformed bodies
2 parents acce991 + c1962e9 commit 4a469c7

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ PHP NEWS
1717
. Fixed bug #80213 (imap_mail_compose() segfaults on certain $bodies). (cmb)
1818
. Fixed bug #80215 (imap_mail_compose() may modify by-val parameters). (cmb)
1919
. Fixed bug #80220 (imap_mail_compose() may leak memory). (cmb)
20+
. Fixed bug #80223 (imap_mail_compose() leaks envelope on malformed bodies).
21+
(cmb)
2022

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

ext/imap/php_imap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,7 +3634,8 @@ PHP_FUNCTION(imap_mail_compose)
36343634

36353635
if (Z_TYPE_P(data) != IS_ARRAY) {
36363636
php_error_docref(NULL, E_WARNING, "body parameter must be a non-empty array");
3637-
RETURN_FALSE;
3637+
RETVAL_FALSE;
3638+
goto done;
36383639
}
36393640
SEPARATE_ARRAY(data);
36403641

@@ -3836,7 +3837,8 @@ PHP_FUNCTION(imap_mail_compose)
38363837

38373838
if (first) {
38383839
php_error_docref(NULL, E_WARNING, "body parameter must be a non-empty array");
3839-
RETURN_FALSE;
3840+
RETVAL_FALSE;
3841+
goto done;
38403842
}
38413843

38423844
if (bod && bod->type == TYPEMULTIPART && (!bod->nested.part || !bod->nested.part->next)) {

ext/imap/tests/bug80223.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #80223 (imap_mail_compose() leaks envelope on malformed bodies)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('imap')) die('skip imap extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
imap_mail_compose([], []);
10+
imap_mail_compose([], [1]);
11+
?>
12+
--EXPECTF--
13+
Warning: imap_mail_compose(): body parameter must be a non-empty array in %s on line %d
14+
15+
Warning: imap_mail_compose(): body parameter must be a non-empty array in %s on line %d

0 commit comments

Comments
 (0)