[asterisk-dev] [Code Review]: Add channel locking around datastore accesses in func_odbc.c.

Tilghman Lesher reviewboard at asterisk.org
Tue Jan 24 11:04:35 CST 2012



> On Jan. 23, 2012, 3:12 p.m., Tilghman Lesher wrote:
> > I disagree with your diagnosis of fixing a potential memory leak.  Since this module doesn't allocate UIDs, it would never be allocated, and thus there's no potential for a memory leak.  Fixing up to use an established central API is fine, though.
> 
> rmudgett wrote:
>     The line "odbc_store = ast_datastore_alloc(&odbc_info, buf)" ast_strdup()'s buf into the odbc_store datastore which was not freed by the removed inline code.

Okay, I was incorrect.  I'd forgotten that I'd allocated a UID for the resultset.


> On Jan. 23, 2012, 3:12 p.m., Tilghman Lesher wrote:
> > /branches/1.8/funcs/func_odbc.c, lines 816-820
> > <https://reviewboard.asterisk.org/r/1687/diff/1/?file=23535#file23535line816>
> >
> >     Probably shouldn't unlock until the second variable is also set.
> 
> rmudgett wrote:
>     I had to delay unlocking the channel until after ~ODBCFIELDS~ was set because resulset->names was referenced.
>     
>     Do you have a particular reason why the channel unlock should be delayed further?

Nope, that should be fine.


- Tilghman


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


On Jan. 23, 2012, 2:14 p.m., rmudgett wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1687/
> -----------------------------------------------------------
> 
> (Updated Jan. 23, 2012, 2:14 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> Accessing the channel datastore list without first locking the channel is bad.
> 
> Adds missing locking around the channel datastore accesses in func_odbc.c.
> 
> * Fixed a potential memory leak when an existing datastore is manually destroyed by inline code instead of calling ast_datastore_free().
> 
> 
> This addresses bug ASTERISK-17948.
>     https://issues.asterisk.org/jira/browse/ASTERISK-17948
> 
> 
> Diffs
> -----
> 
>   /branches/1.8/funcs/func_odbc.c 352199 
> 
> Diff: https://reviewboard.asterisk.org/r/1687/diff
> 
> 
> Testing
> -------
> 
> It compiles. :)
> 
> 
> Thanks,
> 
> rmudgett
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120124/d8749953/attachment.htm>


More information about the asterisk-dev mailing list