Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3618 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48553 invoked by uid 1007); 28 Jul 2003 14:49:15 -0000 Message-ID: <20030728144915.48552.qmail@pb1.pair.com> To: internals@lists.php.net Date: Mon, 28 Jul 2003 15:48:20 +0100 Lines: 52 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Posted-By: 62.49.162.2 Subject: Mem leak in virtual_realpath() in tsrm_virtual_cwd.c From: peterd@telephonetics.co.uk ("Pete Dishman") Hi, I'm currently developing an extension and believe I've found a memory leak in virtual_realpath(). My extension is calling this function via the macro VCWD_REALPATH(). It seems this function allocates memory with CWD_STATE_COPY() but then never frees it. This also seems to be the case in virtual_filepath_ex(), which is the function below. I've been testing with PHP v4.1.1 but I've checked 4.3.2 and the function still has the same problem. virtual_realpath is currently defined as: CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC) { cwd_state new_state; int retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); retval = virtual_file_ex(&new_state, path, NULL); if (!retval) { int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length; memcpy(real_path, new_state.cwd, len); real_path[len] = '\0'; return real_path; } return NULL; } Changing this to include calls to CWD_STATE_FREE(&new_state) before both returns seems to be the correct thing to do and resolves my memory leak. Most of the other functions in this file use CWD_STATE_COPY along with CWD_STATE_FREE, is it just an oversight that these two functions (virtual_realpath and virtual_filepath_ex) don't or is there something more complex going on? I wasn't sure whether to submit this as a bug report or just to send a note here, sorry if I picked the wrong one. Also I'm working on windows and don't currently have CVS access or the ability to produce diff's if this is a definite bug. Thanks in advance, Pete Dishman