<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/2368/">https://reviewboard.asterisk.org/r/2368/</a>
     </td>
    </tr>
   </table>
   <br />









<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/2368/diff/2/?file=33783#file33783line2018" style="color: black; font-weight: bold; text-decoration: underline;">team/dlee/stasis-core/apps/app_minivm.c</a>
    <span style="font-weight: normal;">

     (Diff revision 2)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static int leave_voicemail(struct ast_channel *chan, char *username, struct leave_vm_options *options)</pre></td>

  </tr>
 </tbody>




 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">2017</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="k">struct</span> <span class="n">ast_str</span> <span class="o">*</span><span class="n">uniqueid</span> <span class="o">=</span> <span class="n">ast_str_alloca</span><span class="p">(</span><span class="mi">128</span><span class="p">);</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">128 is not large enough for this allocation. Use (AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2). The + 2 is to allow for the &#39;@&#39; and the null terminator.

Edit: I&#39;ve seen this same allocation get used probably about 15 times throughout this review. Probably would be a good idea to #define the size of a mailbox unique ID in a stasis header file so that all allocations can just be that size.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/2368/diff/2/?file=33784#file33784line7742" style="color: black; font-weight: bold; text-decoration: underline;">team/dlee/stasis-core/apps/app_voicemail.c</a>
    <span style="font-weight: normal;">

     (Diff revision 2)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, char *curdir, int curmsg, char *vm_fmts,</pre></td>

  </tr>
 </tbody>



 
 




 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">7742</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">ast_event_queue_and_cache</span><span class="p">(</span><span class="n">event</span><span class="p">);</span></pre></td>
    <th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">7731</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">stasis_publish_mwi_state</span><span class="p">(</span><span class="n">box</span><span class="p">,</span> <span class="n">mailbox</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">new</span> <span class="o">+</span> <span class="n">urgent</span><span class="p">,</span> <span class="n">old</span><span class="p">);</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Based on the code above, it appears as though &quot;box&quot; may not have an &quot;@context&quot; on it. It does not appear that stasis_publish_mwi_state() is prepared to handle that.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/2368/diff/2/?file=33784#file33784line12622" style="color: black; font-weight: bold; text-decoration: underline;">team/dlee/stasis-core/apps/app_voicemail.c</a>
    <span style="font-weight: normal;">

     (Diff revision 2)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static int handle_subscribe(void *datap)</pre></td>

  </tr>
 </tbody>




 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">12607</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="n">ast_log</span><span class="p">(</span><span class="n">LOG_ERROR</span><span class="p">,</span> <span class="s">&quot;could not allocate a mwi_sub_task</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Hate to be the grammar guy, but I see two things wrong with this:

1) Start with a capital letter.
2) &quot;a mwi_sub_task&quot; sounds weird to me since I would usually pronounce it &quot;an mwi_sub_task&quot;. You can get around this by just saying &quot;Could not allocate mwi_sub_task&quot;

That being said, we tend not to put error messages after allocation failures since ast_calloc() prints an error message already. So you can just remove this error message altogether.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/2368/diff/2/?file=33784#file33784line12628" style="color: black; font-weight: bold; text-decoration: underline;">team/dlee/stasis-core/apps/app_voicemail.c</a>
    <span style="font-weight: normal;">

     (Diff revision 2)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static int handle_subscribe(void *datap)</pre></td>

  </tr>
 </tbody>



 
 




 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">12617</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="k">if</span> <span class="p">(</span><span class="n">ast_taskprocessor_push</span><span class="p">(</span><span class="n">mwi_subscription_tps</span><span class="p">,</span> <span class="n">handle_unsubscribe</span><span class="p">,</span> <span class="n">uniqueid</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></td>
    <th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">12613</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">mwist</span><span class="o">-&gt;</span><span class="n">mailbox</span> <span class="o">=</span> <span class="n">ast_strdup</span><span class="p">(</span><span class="n">mailbox</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">12618</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="n">ast_free</span><span class="p">(</span><span class="n">uniqueid</span><span class="p">);</span></pre></td>
    <th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">12614</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">mwist</span><span class="o">-&gt;</span><span class="n">context</span> <span class="o">=</span> <span class="n">ast_strdup</span><span class="p">(</span><span class="n">context</span><span class="p">);</span></pre></td>
  </tr>

 </tbody>



 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">12615</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">mwist</span><span class="o">-&gt;</span><span class="n">uniqueid</span> <span class="o">=</span> <span class="n">ast_strdup</span><span class="p">(</span><span class="n">change</span><span class="o">-&gt;</span><span class="n">uniqueid</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">12616</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">12617</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="k">if</span> <span class="p">(</span><span class="n">ast_taskprocessor_push</span><span class="p">(</span><span class="n">mwi_subscription_tps</span><span class="p">,</span> <span class="n">handle_subscribe</span><span class="p">,</span> <span class="n">mwist</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">12618</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="n">ast_free</span><span class="p">(</span><span class="n">mwist</span><span class="p">);</span></pre></td>
  </tr>

 </tbody>





 
 

 <tbody>

  <tr>
    <th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">12619</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="p">}</span></pre></td>
    <th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">12619</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="p">}</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">You&#39;ve got some memory leaks here in the case that pushing the task fails. You&#39;ll need to free mwist-&gt;mailbox, mwist-&gt;context, and mwist-&gt;uniqueid.

I suggest making an mwi_sub_task_free() function to call that will free the mwi_sub_task and its duplicated strings. You can call that here, handle_subscribe(), and potentially anywhere else that you would normally be freeing an mwi_sub_task.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/2368/diff/2/?file=33785#file33785line5428" style="color: black; font-weight: bold; text-decoration: underline;">team/dlee/stasis-core/channels/chan_dahdi.c</a>
    <span style="font-weight: normal;">

     (Diff revision 2)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static int send_cwcidspill(struct dahdi_pvt *p)</pre></td>

  </tr>
 </tbody>



 
 




 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">5425</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="n">AST_EVENT_IE_MAILBOX</span><span class="p">,</span> <span class="n">AST_EVENT_IE_PLTYPE_STR</span><span class="p">,</span> <span class="n">mailbox</span><span class="p">,</span></pre></td>
    <th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">5417</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">mwi_message</span> <span class="o">=</span> <span class="n">stasis_cache_get</span><span class="p">(</span><span class="n">stasis_mwi_topic_cached</span><span class="p">(),</span> <span class="n">stasis_mwi_state</span><span class="p">(),</span> <span class="n">ast_str_buffer</span><span class="p">(</span><span class="n">uniqueid</span><span class="p">));</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">You have a refleak. Need to decrease the refcount of mwi_message when you are finished with it.

Edit: It looks like this is done on every call to stasis_cache_get() in this diff. You&#39;re either leaking refs on all of them, or there&#39;s something I&#39;m missing about why you don&#39;t need to unref.</pre>
</div>
<br />



<p>- Mark</p>


<br />
<p>On March 4th, 2013, 2 p.m., opticron wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/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 and David Lee.</div>
<div>By opticron.</div>


<p style="color: grey;"><i>Updated March 4, 2013, 2 p.m.</i></p>




<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;">This converts the usage of the existing event system in Asterisk for MWI to use Stasis as the pubsub backend.

Note: This patch requires the changes in https://reviewboard.asterisk.org/r/2367/ to compile.</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;">MWI distribution to SIP phones has been tested manually as has the pollmailboxes option for voicemail.</pre>
  </td>
 </tr>
</table>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="https://issues.asterisk.org/jira/browse/ASTERISK-21097">ASTERISK-21097</a>


</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>team/dlee/stasis-core/apps/app_minivm.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/apps/app_voicemail.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/channels/chan_dahdi.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/channels/chan_iax2.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/channels/chan_mgcp.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/channels/chan_sip.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/channels/chan_skinny.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/channels/chan_unistim.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/channels/sig_pri.h <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/channels/sig_pri.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/channels/sip/include/sip.h <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/include/asterisk/app.h <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/include/asterisk/xmpp.h <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/main/app.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/main/asterisk.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/res/res_jabber.c <span style="color: grey">(382383)</span></li>

 <li>team/dlee/stasis-core/res/res_xmpp.c <span style="color: grey">(382383)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/2368/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>