Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7940 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79066 invoked by uid 1010); 17 Feb 2004 22:36:10 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 79031 invoked from network); 17 Feb 2004 22:36:09 -0000 Received: from unknown (HELO web13425.mail.yahoo.com) (216.136.175.156) by pb1.pair.com with SMTP; 17 Feb 2004 22:36:09 -0000 Message-ID: <20040217223609.78869.qmail@web13425.mail.yahoo.com> Received: from [24.215.131.184] by web13425.mail.yahoo.com via HTTP; Tue, 17 Feb 2004 14:36:09 PST Date: Tue, 17 Feb 2004 14:36:09 -0800 (PST) To: internals@lists.php.net MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0-2052657777-1077057369=:78187" Subject: Memory Leaks in Win32 PHP 5.0.0b4 From: msisolak@yahoo.com (Michael Sisolak) --0-2052657777-1077057369=:78187 Content-Type: text/plain; charset=us-ascii Content-Id: Content-Disposition: inline I've found two small memory leaks in PHP 5.0.0b4 release when running under Win32 (patches attached). 1) The ISAPI doesn't call sapi_shutdown() so the known_post_content_types hash tables doesn't get freed. 2) In virtual_file_ex (TSRM/tsrm_virtual_cwd.c, line 292) the Win32 API function GetLongPathName() is used to expand the value passed in the path parameter. This code mallocs a new string (called new_path), but then sets the const path function parameter to the new malloc and discards the new_path variable. There is nothing later in the function to ensure that this new malloc is freed. Attached is my take on a fix for this by leaving the new_path variable available so that it can be freed at the end of the function. There may be a cleaner way to do this, but this patch is one approach. Michael Sisolak msisolak@yahoo.com __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html --0-2052657777-1077057369=:78187 Content-Type: text/plain; name="tsrm_virutal_cwd.c.diff.txt" Content-Description: tsrm_virutal_cwd.c.diff.txt Content-Disposition: inline; filename="tsrm_virutal_cwd.c.diff.txt" --- tsrm_virtual_cwd.c.orig Tue Feb 17 12:10:55 2004 +++ tsrm_virtual_cwd.c Tue Feb 17 12:07:59 2004 @@ -292,7 +292,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath) { int path_length = strlen(path); - char *ptr, *path_copy; + char *ptr, *path_copy, *new_path; char *tok = NULL; int ptr_length; cwd_state *old_state; @@ -340,7 +340,6 @@ CWD_API int virtual_file_ex(cwd_state *s #if defined(TSRM_WIN32) { char *dummy = NULL; - char *new_path; int new_path_length; new_path_length = GetLongPathName(path, dummy, 0) + 1; @@ -357,6 +356,7 @@ CWD_API int virtual_file_ex(cwd_state *s path_length = new_path_length; } else { free(new_path); + new_path = NULL; } } #endif @@ -465,6 +465,11 @@ CWD_API int virtual_file_ex(cwd_state *s free(old_state); free(free_path); +#if defined(TSRM_WIN32) + if (new_path) { + free(new_path); + } +#endif #if VIRTUAL_CWD_DEBUG fprintf (stderr, "virtual_file_ex() = %s\n",state->cwd); #endif --0-2052657777-1077057369=:78187 Content-Type: text/plain; name="php5isapi.c.diff.txt" Content-Description: php5isapi.c.diff.txt Content-Disposition: inline; filename="php5isapi.c.diff.txt" --- php5isapi.c.orig Tue Feb 17 17:07:14 2004 +++ php5isapi.c Tue Feb 17 17:03:54 2004 @@ -935,6 +935,7 @@ if (isapi_sapi_module.shutdown) { isapi_sapi_module.shutdown(&sapi_module); } + sapi_shutdown(); tsrm_shutdown(); break; } --0-2052657777-1077057369=:78187--