[asterisk-dev] [Code Review] Fixes dealing with misuse of asprintf()

Mark Michelson reviewboard at asterisk.org
Wed Aug 15 17:09:18 CDT 2012


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

Review request for Asterisk Developers and rmudgett.


Summary
-------

This contains several fixes involving the misuse of asprintf()

* All uses of asprintf() have been changed to ast_asprintf() and all uses of vasprintf() have been changed to ast_vasprintf(). This is because these are typically paired with calls to ast_free(). When using MALLOC_DEBUG, we must pair ast_ allocation calls with ast_free() or else unfun things happen.

* All uses of ast_asprintf() are now checked for failure. The biggest offender here was xmldoc.c. If there are errors in this review, this is the most likely file to find them.

* Any failure cases of ast_asprintf() that result in the allocated memory being potentially referenced later now explicitly NULLs out the pointer because asprintf() does not define what the pointer will be pointing to after an allocation failure.

* Fixed a memory leak in res_config_sqlite3 where an ast_asprintf() call did not have the resultant allocated memory freed.


This addresses bug ASTERISK-20135.
    https://issues.asterisk.org/jira/browse/ASTERISK-20135


Diffs
-----

  /branches/1.8/apps/app_dial.c 370766 
  /branches/1.8/apps/app_queue.c 371141 
  /branches/1.8/apps/app_stack.c 370766 
  /branches/1.8/cdr/cdr_tds.c 370766 
  /branches/1.8/channels/chan_dahdi.c 370766 
  /branches/1.8/channels/chan_oss.c 370766 
  /branches/1.8/channels/chan_sip.c 371198 
  /branches/1.8/funcs/func_odbc.c 370766 
  /branches/1.8/main/file.c 370766 
  /branches/1.8/main/utils.c 370766 
  /branches/1.8/main/xmldoc.c 370766 
  /branches/1.8/pbx/pbx_config.c 370766 
  /branches/1.8/res/res_config_sqlite.c 370766 
  /branches/1.8/res/res_jabber.c 370766 

Diff: https://reviewboard.asterisk.org/r/2071/diff


Testing
-------

Compiled, ran Asterisk, and ran some calls. Nothing catastrophic occurred.


Thanks,

Mark

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


More information about the asterisk-dev mailing list