Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ext/imap/php_imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3622,7 +3622,8 @@ PHP_FUNCTION(imap_mail_compose)

if (Z_TYPE_P(data) != IS_ARRAY) {
php_error_docref(NULL, E_WARNING, "body parameter must be a non-empty array");
RETURN_FALSE;
RETVAL_FALSE;
goto done;
}
SEPARATE_ARRAY(data);

Expand Down Expand Up @@ -3824,7 +3825,8 @@ PHP_FUNCTION(imap_mail_compose)

if (first) {
php_error_docref(NULL, E_WARNING, "body parameter must be a non-empty array");
RETURN_FALSE;
RETVAL_FALSE;
goto done;
}

if (bod && bod->type == TYPEMULTIPART && (!bod->nested.part || !bod->nested.part->next)) {
Expand Down
15 changes: 15 additions & 0 deletions ext/imap/tests/bug80223.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Bug #80223 (imap_mail_compose() leaks envelope on malformed bodies)
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
imap_mail_compose([], []);
imap_mail_compose([], [1]);
?>
--EXPECTF--
Warning: imap_mail_compose(): body parameter must be a non-empty array in %s on line %d

Warning: imap_mail_compose(): body parameter must be a non-empty array in %s on line %d