]> granicus.if.org Git - php/commitdiff
Fix #80226: imap_sort() leaks sortpgm memory
authorChristoph M. Becker <cmbecker69@gmx.de>
Mon, 12 Oct 2020 16:06:53 +0000 (18:06 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Mon, 12 Oct 2020 21:16:31 +0000 (23:16 +0200)
We need to free what we have allocated.

Closes GH-6327.

NEWS
ext/imap/php_imap.c
ext/imap/tests/bug80226.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 6e1a2f78572b569b1ed52bdbe137c1c40b9a9a3d..0a8d47737cb7c35bce6241b98ed60d0833c24303 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ PHP                                                                        NEWS
     (cmb)
   . Fixed bug #80216 (imap_mail_compose() does not validate types/encodings).
     (cmb)
+  . Fixed bug #80226 (imap_sort() leaks sortpgm memory). (cmb)
 
 - MySQLnd:
   . Fixed bug #80115 (mysqlnd.debug doesn't recognize absolute paths with
index 5f05a0c359c34c8f9135f7ac58c835c3dff3797d..a88c329b01dff1a232378c30512b28ecb0596a1f 100644 (file)
@@ -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 (file)
index 0000000..95ec235
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Bug #80226 (imap_sort() leaks sortpgm memory)
+--SKIPIF--
+<?php
+require_once(__DIR__.'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(__DIR__.'/imap_include.inc');
+$stream = imap_open($default_mailbox, $username, $password);
+imap_sort($stream, SORTFROM, 0);
+?>
+--EXPECT--