From: Chuck Hagenbuch Date: Fri, 18 Aug 2000 16:02:27 +0000 (+0000) Subject: use estrndup and efree to hopefully avoid both munging of arguments and X-Git-Tag: php-4.0.2RC1~68 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c4b2498baea2a1eb060652c364e81889433ce778;p=php use estrndup and efree to hopefully avoid both munging of arguments and leaking memory. --- diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 18253c46f4..941b2aa948 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -3385,6 +3385,7 @@ PHP_FUNCTION(imap_search) int ind, ind_type, args; pils *imap_le_struct; long flags; + char *search_criteria; MESSAGELIST *cur; IMAPLS_FETCH(); @@ -3395,6 +3396,7 @@ PHP_FUNCTION(imap_search) convert_to_long_ex(streamind); convert_to_string_ex(criteria); + search_criteria = estrndup(Z_STRVAL_PP(criteria), Z_STRLEN_PP(criteria)); if (args == 2) { flags = SE_FREE; @@ -3411,7 +3413,7 @@ PHP_FUNCTION(imap_search) } IMAPG(imap_messages) = NIL; - mail_search_full(imap_le_struct->imap_stream, NIL, mail_criteria(cpystr(Z_STRVAL_PP(criteria))), flags); + mail_search_full(imap_le_struct->imap_stream, NIL, mail_criteria(search_criteria), flags); if (IMAPG(imap_messages) == NIL) { RETURN_FALSE; } @@ -3423,6 +3425,7 @@ PHP_FUNCTION(imap_search) cur = cur->next; } mail_free_messagelist(&IMAPG(imap_messages)); + efree(search_criteria); } /* }}} */