diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 5f05a0c359c34..a88c329b01dff 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -3189,6 +3189,7 @@ PHP_FUNCTION(imap_sort) slst = mail_sort(imap_le_struct->imap_stream, (argc == 6 ? ZSTR_VAL(charset) : NIL), spg, mypgm, (argc >= 4 ? flags : NIL)); + mail_free_sortpgm(&mypgm); if (spg && !(flags & SE_FREE)) { mail_free_searchpgm(&spg); } diff --git a/ext/imap/tests/bug80226.phpt b/ext/imap/tests/bug80226.phpt new file mode 100644 index 0000000000000..fffa0c09fa4b5 --- /dev/null +++ b/ext/imap/tests/bug80226.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #80226 (imap_sort() leaks sortpgm memory) +--SKIPIF-- + +--FILE-- + +--EXPECT--