libattr - severe memory leaks from attr_copy_file()
Eric Sandeen
sandeen at sandeen.net
Thu Feb 19 10:31:12 CST 2009
Zdenek Prikryl wrote:
>> And the variable, text, is assigned straight away before any use,
>> so I missed where the problem is.
>>
>> --Tim
>
> The memory leak is really there. Look:
>
> 54 attr_parse_attr_conf(struct error_context *ctx)
> ...
> 66 repeat:
> 67 text = malloc(size_guess + 1);
> 68 if (!text)
> 69 goto fail;
> 70
> 71 if ((file = fopen(ATTR_CONF, "r")) == NULL) {
> 72 if (errno == ENOENT)
> 73 return 0;
> 74 goto fail;
> 75 }
>
> Let's say that malloc() on the line 67 success, so we have text != NULL. Then,
> fopen() on the line 71 fails and errno == ENOENT. In that case
> attr_parse_attr_conf() simply returns 0, but text isn't freed. That's the point,
> where memory leaks arise. I rewrote the patch, so now is more simpler.
The patch you attached looks good to me, thanks.
-Eric
More information about the xfs
mailing list