[asterisk-dev] murf: branch 1.4 r152535 - in /branches/1.4: apps/ funcs/ include/asterisk/ res/

Mark Michelson mmichelson at digium.com
Mon Nov 3 15:24:56 CST 2008


Russell Bryant wrote:
> Steve Murphy wrote: 
>> By the way, I found some parking related code in main/pbx.c that I would
>> assume
>> needs to be changed to protect against illegal access after the bridge
>> returns AST_PBX_KEEPALIVE in __ast_pbx_run()...
>>
>> -       ast_set2_flag(c, autoloopflag, AST_FLAG_IN_AUTOLOOP);
>> -       ast_clear_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN); /* from one round
>> to the next, make sure this gets cleared */
>> -       pbx_destroy(c->pbx);
>> -       c->pbx = NULL;
>> -       if (res != AST_PBX_KEEPALIVE)
>> +       if (res != AST_PBX_KEEPALIVE) {
>> +               ast_set2_flag(c, autoloopflag, AST_FLAG_IN_AUTOLOOP);
>> +               ast_clear_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN); /* from
>> one round to the next, make sure this gets cleared */
>> +               pbx_destroy(c->pbx);
>> +               c->pbx = NULL;
>>                 ast_hangup(c);
>> +       }
>>         return 0;
>>  }
>>

<snip>

> You are correct that the existing code is not safe.  However, in the 
> existing code, you have the potential for a crash.  In your modified 
> version, you have a memory leak, as the ast_pbx isn't getting cleared up 
> like it is supposed to.
> 

For my education, where is the memory leak? What else is required besides 
pbx_destroy()?

Mark Michelson



More information about the asterisk-dev mailing list