<h1>Project "FreeSWITCH Source" received a push.</h1>

<h2>branch: master updated</h2>
<pre>
       via: 0e841a5f14810514ee60562481c405d7fb560e72 (commit)
      from: a93623618b83fb08f2a0a728800f431856b29f92 (commit)


</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
FS-3040/FS-1742: use 1 sql query for message count in a way that is portable and doesn&#39;t segfault

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #000080; font-weight: bold">index 80b011e..894e49a 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #800080; font-weight: bold">@@ -1011,6 +1011,11 @@ typedef struct msg_cnt_callback msg_cnt_callback_t;</span>
 static int message_count_callback(void *pArg, int argc, char **argv, char **columnNames)
 {
         msg_cnt_callback_t *cbt = (msg_cnt_callback_t *) pArg;
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (argc &lt; 3 || zstr(argv[0]) || zstr(argv[1]) || zstr(argv[2])) {</span>
<span style="color: #00A000">+                return -1;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         if (atoi(argv[0]) == 1) {        /* UnRead */
                 if (!strcasecmp(argv[1], &quot;A_URGENT&quot;)) {        /* Urgent */
                         cbt-&gt;total_new_urgent_messages = atoi(argv[2]);
<span style="color: #800080; font-weight: bold">@@ -1263,7 +1268,7 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
 {
         char msg_count[80] = &quot;&quot;;
         msg_cnt_callback_t cbt = { 0 };
<span style="color: #A00000">-        char sql[256];</span>
<span style="color: #00A000">+        char *sql;</span>
         char *myid = NULL;
 
 
<span style="color: #800080; font-weight: bold">@@ -1277,11 +1282,20 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
 
         myid = resolve_id(id_in, domain_name, &quot;message-count&quot;);
 
<span style="color: #A00000">-        switch_snprintf(sql, sizeof(sql),</span>
<span style="color: #A00000">-                                        &quot;select read_epoch=0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; group by read_epoch=0,read_flags;&quot;,</span>
<span style="color: #A00000">-                                        myid, domain_name, myfolder);</span>
<span style="color: #00A000">+        sql = switch_mprintf(</span>
<span style="color: #00A000">+                                                 &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where &quot;</span>
<span style="color: #00A000">+                                                 &quot;username=&#39;%q&#39; and domain=&#39;%q&#39; and in_folder=&#39;%q&#39; and read_epoch=0 &quot;</span>
<span style="color: #00A000">+                                                 &quot;group by read_flags &quot;</span>
<span style="color: #00A000">+                                                 &quot;union &quot;</span>
<span style="color: #00A000">+                                                 &quot;select 0, read_flags, count(read_epoch) from voicemail_msgs where &quot;</span>
<span style="color: #00A000">+                                                 &quot;username=&#39;%q&#39; and domain=&#39;%q&#39; and in_folder=&#39;%q&#39; and read_epoch&lt;&gt;0 &quot;</span>
<span style="color: #00A000">+                                                 &quot;group by read_flags;&quot;,</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                                 myid, domain_name, myfolder,</span>
<span style="color: #00A000">+                                                 myid, domain_name, myfolder);</span>
 
         vm_execute_sql_callback(profile, profile-&gt;mutex, sql, message_count_callback, &amp;cbt);
<span style="color: #00A000">+        free(sql);</span>
 
         *total_new_messages = cbt.total_new_messages + cbt.total_new_urgent_messages;
         *total_new_urgent_messages = cbt.total_new_urgent_messages;
</pre></div>
========================================================================<pre>

Summary of changes:
 src/mod/applications/mod_voicemail/mod_voicemail.c |   22 ++++++++++++++++---
 1 files changed, 18 insertions(+), 4 deletions(-)
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH Source</p>