[asterisk-dev] [Code Review] 2734: Check result of ast_var_assign when out of mem

svnbot reviewboard at asterisk.org
Tue Aug 6 03:15:11 CDT 2013


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

(Updated Aug. 6, 2013, 3:15 a.m.)


Status
------

This change has been marked as submitted.


Review request for Asterisk Developers.


Changes
-------

Committed in revision 396279


Repository: Asterisk


Description
-------

Due to a different issue, my asterisk was out of memory.

It crashed first when it tried to AST_LIST_INSERT_HEAD(headp, newvariable, entries); a newvariable that was NULL.

#0  0x0000000000535b30 in pbx_builtin_setvar_helper (chan=0x7fb8fd85d368, name=0x7fb93c03ed60 "__record_call", value=0x7fb940a90240 "no") at pbx.c:10202
10202			AST_LIST_INSERT_HEAD(headp, newvariable, entries);
(gdb) back
#0  0x0000000000535b30 in pbx_builtin_setvar_helper (chan=0x7fb8fd85d368, name=0x7fb93c03ed60 "__record_call", value=0x7fb940a90240 "no") at pbx.c:10202
#1  0x00007fb94b0a4e1f in sip_new (i=0x94d7ee8, state=0, title=0x7fb940a90ce0 "152960003", linkedid=0x7fb93c058126 "somehost-1374224633.26491") at chan_sip.c:7346
#2  0x00007fb94b10d9d6 in sip_request_call (type=0x7fb940a91250 "SIP", cap=0x7fb833f3afc0, requestor=0x7fb8fd80b9c8, data=0x7fb940a92190, cause=0x7fb940a91b74) at chan_sip.c:27815
...

This patch checks all ast_var_assign() calls found in the 1.8 branch for NULL.

Note that I didn't sprinkle the code with "out of memory" log messages for three reasons: (a) you'll probably notice that you're out of mem anyway, (b) the ast_calloc already mentiones that we're out of mem, (c) the ast_log() call itself has the potential for crashing because of recursion (out of stack space) (*)


(*) E.g. here:
        /* Create a new logging message */
        if (!(logmsg = ast_calloc_with_stringfields(1, struct logmsg, res + 128)))
                return;


Diffs
-----

  /branches/1.8/apps/app_playback.c 396085 
  /branches/1.8/apps/app_stack.c 396085 
  /branches/1.8/funcs/func_global.c 396085 
  /branches/1.8/funcs/func_strings.c 396085 
  /branches/1.8/main/cdr.c 396085 
  /branches/1.8/main/pbx.c 396085 
  /branches/1.8/pbx/pbx_dundi.c 396085 
  /branches/1.8/pbx/pbx_loopback.c 396085 
  /branches/1.8/utils/extconf.c 396085 

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


Testing
-------

It compiles.


Thanks,

wdoekes

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


More information about the asterisk-dev mailing list