]> granicus.if.org Git - php/commitdiff
Fix #80239: imap_rfc822_write_address() leaks memory
authorChristoph M. Becker <cmbecker69@gmx.de>
Thu, 15 Oct 2020 10:51:10 +0000 (12:51 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Thu, 15 Oct 2020 10:54:53 +0000 (12:54 +0200)
We have to free the address when we're finished with it.

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

diff --git a/NEWS b/NEWS
index fb966d9b7214ec8c5f7ec3c97fbe67471c77431b..42b663cf409a2716599a99b1733b13ee4eefc433 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ PHP                                                                        NEWS
 
 - IMAP:
   . Fixed bug #64076 (imap_sort() does not return FALSE on failure). (cmb)
+  . Fixed bug #80239 (imap_rfc822_write_address() leaks memory). (cmb)
 
 29 Oct 2020, PHP 7.3.24
 
index db144b0d49fc37210527b1bfeb9ff9bc5a9ec9b0..4acdc01338b32696c69fc1075540dea90cf811e6 100644 (file)
@@ -2305,6 +2305,7 @@ PHP_FUNCTION(imap_subscribe)
        } else {
                RETURN_FALSE;
        }
+       mail_free_address(&addr);
 }
 /* }}} */
 
diff --git a/ext/imap/tests/imap_rfc822_write_address_basic.phpt b/ext/imap/tests/imap_rfc822_write_address_basic.phpt
new file mode 100644 (file)
index 0000000..92e988c
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+imap_rfc822_write_address() : basic functionality
+--SKIPIF--
+<?php
+if (!extension_loaded('imap')) die('skip imap extension not available');
+?>
+--FILE--
+<?php
+var_dump(imap_rfc822_write_address('me', 'example.com', 'My Name'));
+?>
+--EXPECT--
+string(24) "My Name <me@example.com>"