minaco2 / distcc

Automatically exported from code.google.com/p/distcc
GNU General Public License v2.0
0 stars 0 forks source link

Memory leak on cygwin platform #116

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. What version of distcc are you using (e.g. "2.7.1")?  

svn checkout http://distcc.googlecode.com/svn/trunk/ distcc-read-only
Go through source code and find some possible memory leak on cygwin platform.

2. What platform are you running on (e.g. "Red Hat 8.0", "HP-UX 11.11")?  What 
compilare are you using ("gcc 3.3")?  

bjcheny@bjcheny-work ~
$ uname -a
CYGWIN_NT-5.1 bjcheny-work 1.7.15(0.260/5/3) 2012-05-09 10:25 i686 Cygwin
bjcheny@bjcheny-work ~
$ cc --version
cc (GCC) 4.5.3

3. What were you trying to do (e.g. "install distcc", "build Mozilla")?

Study source code of distcc and build it on cygwin platform.

4. What went wrong?  Did you get an error message, did it hang, did it build a 
program that didn't work, did it not distribute compilation to machines that 
ought to get it?

In int dcc_get_tmp_top(const char **p_ret) in tempfile.c, the below code may 
have issue of memory leak on cygwin platform:

    char *s = malloc(MAXPATHLEN+1);
    GetTempPath(MAXPATHLEN+1,s);
    if ((ret = dcc_add_cleanup(s))) {
        free(s);
        return ret;
    }
    *p_ret = s;

The logic for cygwin is a little bit different from that on linux. 
It requires to malloc buffer as "s" to save result from w32 API GetTempPath().
However, no free action after return buffer of s, on cygwin platform.

Btw, I wonder this kind of issue in code should be put here or groups of 
patches. Let me know. Thanks.

Original issue reported on code.google.com by compan...@gmail.com on 11 Aug 2012 at 8:17