summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-10-15 12:51:10 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-10-15 12:54:53 +0200
commit5941b30bb889afcdd7684f9e0ce05ce72bb8256b (patch)
tree88a91a67bd90046db231a93e5aab09930b29a638
parenta29016d70d72dacb688b4df334508edb550d688f (diff)
downloadphp-git-5941b30bb889afcdd7684f9e0ce05ce72bb8256b.tar.gz
Fix #80239: imap_rfc822_write_address() leaks memory
We have to free the address when we're finished with it.
-rw-r--r--NEWS1
-rw-r--r--ext/imap/php_imap.c1
-rw-r--r--ext/imap/tests/imap_rfc822_write_address_basic.phpt12
3 files changed, 14 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index fb966d9b72..42b663cf40 100644
--- 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
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index db144b0d49..4acdc01338 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -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
index 0000000000..92e988c9c9
--- /dev/null
+++ b/ext/imap/tests/imap_rfc822_write_address_basic.phpt
@@ -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>"