Skip to content

Commit 0443c82

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #80223: imap_mail_compose() leaks envelope on malformed bodies
2 parents 5a8958f + 4a469c7 commit 0443c82

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
@@ -10,6 +10,8 @@ PHP NEWS
1010
. Fixed bug #80213 (imap_mail_compose() segfaults on certain $bodies). (cmb)
1111
. Fixed bug #80215 (imap_mail_compose() may modify by-val parameters). (cmb)
1212
. Fixed bug #80220 (imap_mail_compose() may leak memory). (cmb)
13+
. Fixed bug #80223 (imap_mail_compose() leaks envelope on malformed bodies).
14+
(cmb)
1315

1416
- Opcache:
1517
. Fixed bug #80184 (Complex expression in while / if statements resolves to

ext/imap/php_imap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3172,7 +3172,8 @@ PHP_FUNCTION(imap_mail_compose)
31723172
if (Z_TYPE_P(data) != IS_ARRAY) {
31733173
// TODO ValueError
31743174
php_error_docref(NULL, E_WARNING, "body parameter must be a non-empty array");
3175-
RETURN_FALSE;
3175+
RETVAL_FALSE;
3176+
goto done;
31763177
}
31773178
SEPARATE_ARRAY(data);
31783179

@@ -3375,7 +3376,8 @@ PHP_FUNCTION(imap_mail_compose)
33753376
if (first) {
33763377
// TODO ValueError
33773378
php_error_docref(NULL, E_WARNING, "body parameter must be a non-empty array");
3378-
RETURN_FALSE;
3379+
RETVAL_FALSE;
3380+
goto done;
33793381
}
33803382

33813383
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)