[asterisk-dev] memory leak in chan_agent.c
Mihai Balea
mihai at hates.ms
Wed Mar 7 15:29:57 MST 2007
On Mar 7, 2007, at 5:14 PM, Christian wrote:
> Russell Bryant wrote:
>> Christian wrote:
>>> i was just reading chan_agent.c (svn 1.4 head) and found that in
>>> "add_agent" (line :299) there is a "parse" variable allocated which
>>> never seems to be freed. Is that correct or does the app_args_parse
>>> stuff magically free that later ? I assume this is a memory leak, if
>>> somebody confirms i'll fix that and check for other mem leaks
>>> like that.
>>
>> parse = ast_strdupa(agent);
>>
>> Note that this is strdupa, and not strdup. This function just
>> allocates memory on the stack, so there is no need to free it.
>>
> oh .. sorry didn't look at the implementation :) thx. for the hint,
> will use it next time when i need a copy only locally :)
>
Not sure if that's a good idea... the use of alloca and friends is
discouraged by the C luminaries.
Take a look at the alloca man page for an explanation.
Mihai
More information about the asterisk-dev
mailing list