<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://reviewboard.asterisk.org/r/2734/">https://reviewboard.asterisk.org/r/2734/</a>
     </td>
    </tr>
   </table>
   <br />
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>
<div>Review request for Asterisk Developers.</div>
<div>By wdoekes.</div>
<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">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;
</pre>
  </td>
 </tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">It compiles.</pre>
  </td>
 </tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
 <li>/branches/1.8/apps/app_playback.c <span style="color: grey">(396085)</span></li>
 <li>/branches/1.8/apps/app_stack.c <span style="color: grey">(396085)</span></li>
 <li>/branches/1.8/funcs/func_global.c <span style="color: grey">(396085)</span></li>
 <li>/branches/1.8/funcs/func_strings.c <span style="color: grey">(396085)</span></li>
 <li>/branches/1.8/main/cdr.c <span style="color: grey">(396085)</span></li>
 <li>/branches/1.8/main/pbx.c <span style="color: grey">(396085)</span></li>
 <li>/branches/1.8/pbx/pbx_dundi.c <span style="color: grey">(396085)</span></li>
 <li>/branches/1.8/pbx/pbx_loopback.c <span style="color: grey">(396085)</span></li>
 <li>/branches/1.8/utils/extconf.c <span style="color: grey">(396085)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2734/diff/" style="margin-left: 3em;">View Diff</a></p>
  </td>
 </tr>
</table>
  </div>
 </body>
</html>