From 84c243d3cce9ecf39ac03304b896ba46d4c95d4d Mon Sep 17 00:00:00 2001 From: "Thies C. Arntzen" Date: Sun, 18 Feb 2001 18:15:01 +0000 Subject: [PATCH] fixed a possible double-free --- ext/imap/php_imap.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index ffaca95762..6ae8862194 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -187,8 +187,15 @@ void mail_close_it(zend_rsrc_list_entry *rsrc) mail_close_full(imap_le_struct->imap_stream, imap_le_struct->flags); - efree(IMAPG(imap_user)); - efree(IMAPG(imap_password)); + if (IMAPG(imap_user)) { + efree(IMAPG(imap_user)); + IMAPG(imap_user) = 0; + } + if (IMAPG(imap_password)) { + efree(IMAPG(imap_password)); + IMAPG(imap_password) = 0; + } + efree(imap_le_struct); } @@ -638,6 +645,14 @@ void imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) } } + if (IMAPG(imap_user)) { + efree(IMAPG(imap_user)); + } + + if (IMAPG(imap_password)) { + efree(IMAPG(imap_password)); + } + IMAPG(imap_user) = estrndup(Z_STRVAL_PP(user), Z_STRLEN_PP(user)); IMAPG(imap_password) = estrndup(Z_STRVAL_PP(passwd), Z_STRLEN_PP(passwd)); -- 2.50.1