Subject: Re: [PATCH] Fix memory leaks in read_tree_recursive()

From: Jonas Fonseca <[email-masked]>
Date: Thu, 5 May 2005 02:08:15 +0200

Junio C Hamano <[email-masked]> wrote Wed, May 04, 2005:
> >>>>> "JF" == Jonas Fonseca <[email-masked]> writes:
> 
> JF> This patch fixes memory leaks in the error path of
> JF> read_tree_recursive().
> 
> The leak seems to be real but what is "mem_free"?

That mem_free() was a bad habbit from the project I usually work on.

> Has it been compile tested?

No, but the second patch has.

BTW, when compiling git on a FreeBSD box I get these warnings:

date.c: In function `parse_date':
date.c:414: warning: long unsigned int format, time_t arg (arg 4)
date.c:414: warning: long unsigned int format, time_t arg (arg 4)
date.c: In function `datestamp':
date.c:427: warning: long unsigned int format, time_t arg (arg 4)
date.c:427: warning: long unsigned int format, time_t arg (arg 4)
tar-tree.c: In function `write_header':
tar-tree.c:249: warning: long unsigned int format, time_t arg (arg 3)
local-pull.c: In function `fetch':
local-pull.c:73: warning: long int format, different type arg (arg 4)

because time_t is defined as int32_t.  Don't know if they are worth
fixing at this point.

> JF> @@ -39,14 +39,18 @@
> JF>  		if (S_ISDIR(mode)) {
> JF>  			int retval;
>  
> JF> ...
> JF> -			if (!eltbuf || strcmp(elttype, "tree"))
> JF> +			if (!eltbuf || strcmp(elttype, "tree")) {
> JF> +				if (eltbuf) mem_free(eltbuf);
> JF>  				return -1;
> 
> Btw, who is putting this header in your mail?  It does not make
> sense to me unless Jonas is pseudonym for Linus...
> 
>   Mail-Followup-To: Linus Torvalds <[email-masked]>, [email-masked] 

Maybe because Mutt knows I am subscribe to this mailing list and assumes
I don't want to have mail addressed directly to my email address?

I just hit 'g'.

-- 
Jonas Fonseca