Skip to content

Commit 8488c34

Browse files
committed
Fix #80226: imap_sort() leaks sortpgm memory
We need to free what we have allocated. Closes GH-6327.
1 parent 73e43b6 commit 8488c34

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PHP NEWS
1717
(cmb)
1818
. Fixed bug #80216 (imap_mail_compose() does not validate types/encodings).
1919
(cmb)
20+
. Fixed bug #80226 (imap_sort() leaks sortpgm memory). (cmb)
2021

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

ext/imap/php_imap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,6 +3189,7 @@ PHP_FUNCTION(imap_sort)
31893189

31903190
slst = mail_sort(imap_le_struct->imap_stream, (argc == 6 ? ZSTR_VAL(charset) : NIL), spg, mypgm, (argc >= 4 ? flags : NIL));
31913191

3192+
mail_free_sortpgm(&mypgm);
31923193
if (spg && !(flags & SE_FREE)) {
31933194
mail_free_searchpgm(&spg);
31943195
}

ext/imap/tests/bug80226.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #80226 (imap_sort() leaks sortpgm memory)
3+
--SKIPIF--
4+
<?php
5+
require_once(__DIR__.'/skipif.inc');
6+
?>
7+
--FILE--
8+
<?php
9+
require_once(__DIR__.'/imap_include.inc');
10+
$stream = imap_open($default_mailbox, $username, $password);
11+
imap_sort($stream, SORTFROM, 0);
12+
?>
13+
--EXPECT--

0 commit comments

Comments
 (0)