<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14812">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">WIP<br><br>Change-Id: Ie8a7db6a0b68f3995b0846bbb733a21909ba44e5<br>---<br>M apps/app_voicemail.c<br>1 file changed, 26 insertions(+), 31 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/12/14812/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c</span><br><span>index 742c9c3..24078f8 100644</span><br><span>--- a/apps/app_voicemail.c</span><br><span>+++ b/apps/app_voicemail.c</span><br><span>@@ -1017,20 +1017,18 @@</span><br><span> int old_new;</span><br><span> int old_old;</span><br><span> char *uniqueid;</span><br><span style="color: hsl(0, 100%, 40%);">- char mailbox[0];</span><br><span style="color: hsl(120, 100%, 40%);">+ char *mailbox;</span><br><span> };</span><br><span> </span><br><span> struct mwi_sub_task {</span><br><span style="color: hsl(0, 100%, 40%);">- const char *mailbox;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *context;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *uniqueid;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *mailbox;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *uniqueid;</span><br><span> };</span><br><span> </span><br><span> static void mwi_sub_task_dtor(struct mwi_sub_task *mwist)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_free((void *) mwist->mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_free((void *) mwist->context);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_free((void *) mwist->uniqueid);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(mwist->mailbox);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(mwist->uniqueid);</span><br><span> ast_free(mwist);</span><br><span> }</span><br><span> </span><br><span>@@ -13364,31 +13362,20 @@</span><br><span> </span><br><span> static int handle_subscribe(void *datap)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int len;</span><br><span> struct mwi_sub *mwi_sub;</span><br><span> struct mwi_sub_task *p = datap;</span><br><span style="color: hsl(0, 100%, 40%);">- size_t context_len;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- len = sizeof(*mwi_sub) + 1;</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(p->mailbox))</span><br><span style="color: hsl(0, 100%, 40%);">- len += strlen(p->mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- context_len = strlen(p->context) + 1; /* Allow for seperator */</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(p->context))</span><br><span style="color: hsl(0, 100%, 40%);">- len += context_len;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!(mwi_sub = ast_calloc(1, len)))</span><br><span style="color: hsl(120, 100%, 40%);">+ mwi_sub = ast_calloc(1, sizeof(*mwi_sub));</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!mwi_sub) {</span><br><span> return -1;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- mwi_sub->uniqueid = ast_strdup(p->uniqueid);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(p->mailbox))</span><br><span style="color: hsl(0, 100%, 40%);">- strcpy(mwi_sub->mailbox, p->mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(p->context)) {</span><br><span style="color: hsl(0, 100%, 40%);">- strcat(mwi_sub->mailbox, "@");</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_string(mwi_sub->mailbox, p->context, context_len);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ mwi_sub->uniqueid = p->uniqueid;</span><br><span style="color: hsl(120, 100%, 40%);">+ mwi_sub->mailbox = p->mailbox;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The sub now owns the memory */</span><br><span style="color: hsl(120, 100%, 40%);">+ p->mailbox = p->uniqueid = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> AST_RWLIST_WRLOCK(&mwi_subs);</span><br><span> AST_RWLIST_INSERT_TAIL(&mwi_subs, mwi_sub, entry);</span><br><span> AST_RWLIST_UNLOCK(&mwi_subs);</span><br><span>@@ -13418,7 +13405,7 @@</span><br><span> char *context;</span><br><span> char *mailbox;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- mwist = ast_calloc(1, (sizeof(*mwist)));</span><br><span style="color: hsl(120, 100%, 40%);">+ mwist = ast_calloc(1, sizeof(*mwist));</span><br><span> if (!mwist) {</span><br><span> return;</span><br><span> }</span><br><span>@@ -13426,13 +13413,21 @@</span><br><span> /* The topic name is prefixed with "mwi:all/" as this is a pool topic */</span><br><span> topic = stasis_topic_name(change->topic) + 8;</span><br><span> if (separate_mailbox(ast_strdupa(topic), &mailbox, &context)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_free(mwist);</span><br><span style="color: hsl(120, 100%, 40%);">+ mwi_sub_task_dtor(mwist);</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- mwist->mailbox = ast_strdup(mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">- mwist->context = ast_strdup(context);</span><br><span style="color: hsl(0, 100%, 40%);">- mwist->uniqueid = ast_strdup(change->uniqueid);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* separate_mailbox() guarantees a non-NULL, non-empty mailbox and context */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_asprintf(&mwist->mailbox, "%s@%s", mailbox, context) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ mwi_sub_task_dtor(mwist);</span><br><span style="color: hsl(120, 100%, 40%);">+ return;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ mwist->uniqueid = ast_strdup(change->uniqueid ?: "");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!mwist->uniqueid) {</span><br><span style="color: hsl(120, 100%, 40%);">+ mwi_sub_task_dtor(mwist);</span><br><span style="color: hsl(120, 100%, 40%);">+ return;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> if (ast_taskprocessor_push(mwi_subscription_tps, handle_subscribe, mwist) < 0) {</span><br><span> mwi_sub_task_dtor(mwist);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14812">change 14812</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/14812"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Ie8a7db6a0b68f3995b0846bbb733a21909ba44e5 </div>
<div style="display:none"> Gerrit-Change-Number: 14812 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>