[asterisk-dev] [Code Review] 4347: Investigate and fix memory leaks in Asterisk

Kevin Harwell reviewboard at asterisk.org
Tue Jan 20 12:26:45 CST 2015



> On Jan. 19, 2015, 11:50 a.m., rmudgett wrote:
> > branches/13/res/parking/parking_applications.c, line 613
> > <https://reviewboard.asterisk.org/r/4347/diff/1/?file=70612#file70612line613>
> >
> >     Was there a problem with this already holding a retriever snapshot?  Otherwise this should just be an ast_assert() for paranoia's sake since it should always be NULL at this point.

hmmm, well it has been a few days and I can't remember exactly.  I want to say it might have been.  Something pointed me to this code leak wise and this is what I ended up finding. I'll probably leave it as is to be safe.


> On Jan. 19, 2015, 11:50 a.m., rmudgett wrote:
> > branches/13/res/res_stasis.c, lines 1820-1821
> > <https://reviewboard.asterisk.org/r/4347/diff/1/?file=70619#file70619line1820>
> >
> >     1) The Doxygen for this function needs to be updated for all of the parameters.
> >     
> >     2) The only caller of this function in res/ari/resource_events.c has a code path that leaks the json_variables parameter.
> >     
> >     3) After calling this function, the caller needs to unref the jason_variables.  Either that or the semantics of this function needs to change so that the ref is passed to this function.

There is no leak here.  The caller of ast_ari_events_user_event() handles the lifetime of the passed in "args" variable.  ast_json_object_get() returns a pointer to another object contained within, but does not bump the ref for it, so it will be freed when "args" is released.  However, in this case it is passed into stasis_app_user_event() and becomes part of the event blob.  Once "args" goes away so do the variables, so a ref is then added for it once it becomes the blob which then gets released when the ast_multi_object_blob gets released.


- Kevin


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4347/#review14228
-----------------------------------------------------------


On Jan. 15, 2015, 1:15 p.m., Kevin Harwell wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4347/
> -----------------------------------------------------------
> 
> (Updated Jan. 15, 2015, 1:15 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Bugs: ASTERISK-24693
>     https://issues.asterisk.org/jira/browse/ASTERISK-24693
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> This patch fixes a few memory leaks that were found in Asterisk.
> 
> 
> Diffs
> -----
> 
>   branches/13/rest-api-templates/param_parsing.mustache 430684 
>   branches/13/res/res_stasis.c 430684 
>   branches/13/res/res_pjsip_pubsub.c 430684 
>   branches/13/res/res_pjsip_mwi.c 430684 
>   branches/13/res/res_pjsip/pjsip_global_headers.c 430684 
>   branches/13/res/res_ari_events.c 430684 
>   branches/13/res/res_ari_endpoints.c 430684 
>   branches/13/res/res_ari_channels.c 430684 
>   branches/13/res/parking/parking_applications.c 430684 
>   branches/13/channels/chan_iax2.c 430684 
> 
> Diff: https://reviewboard.asterisk.org/r/4347/diff/
> 
> 
> Testing
> -------
> 
> Some manual testing done along with inspection of log files and malloc_debug data.  Also ran relevant unit and testsuite tests.
> 
> 
> Thanks,
> 
> Kevin Harwell
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150120/118c57e5/attachment.html>


More information about the asterisk-dev mailing list