<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7074">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_config_wizard: Fix leaks and add check for malloc failure.<br><br>wizard_apply_handler():<br>- Free host if we fail to add it to the vector.<br><br>wizard_mapped_observer():<br>- Check for otw allocation failure.<br>- Free otw if we fail to add it to the vector.<br><br>Change-Id: Ib5d3bcabbd9c24dd8a3c9cc692a794a5f60243ad<br>---<br>M res/res_pjsip_config_wizard.c<br>1 file changed, 13 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/74/7074/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_config_wizard.c b/res/res_pjsip_config_wizard.c<br>index 1526dc2..3a761a7 100644<br>--- a/res/res_pjsip_config_wizard.c<br>+++ b/res/res_pjsip_config_wizard.c<br>@@ -1001,7 +1001,10 @@<br> char *hosts = ast_strdupa(remote_hosts);<br> <br> while ((host = ast_strsep(&hosts, ',', AST_STRSEP_TRIM))) {<br>- AST_VECTOR_APPEND(&remote_hosts_vector, ast_strdup(host));<br>+ host = ast_strdup(host);<br>+ if (host && AST_VECTOR_APPEND(&remote_hosts_vector, host)) {<br>+ ast_free(host);<br>+ }<br> }<br> }<br> <br>@@ -1168,15 +1171,22 @@<br> /* We're only interested in memory wizards with the pjsip_wizard tag. */<br> if (wizard_args && !strcmp(wizard_args, "pjsip_wizard")) {<br> otw = ast_malloc(sizeof(*otw) + strlen(object_type) + 1);<br>+ if (!otw) {<br>+ return;<br>+ }<br>+<br> otw->sorcery = sorcery;<br> otw->wizard = wizard;<br> otw->wizard_data = wizard_data;<br> otw->last_config = NULL;<br> strcpy(otw->object_type, object_type); /* Safe */<br> AST_VECTOR_RW_WRLOCK(&object_type_wizards);<br>- AST_VECTOR_APPEND(&object_type_wizards, otw);<br>+ if (AST_VECTOR_APPEND(&object_type_wizards, otw)) {<br>+ ast_free(otw);<br>+ } else {<br>+ ast_debug(1, "Wizard mapped for object_type '%s'\n", object_type);<br>+ }<br> AST_VECTOR_RW_UNLOCK(&object_type_wizards);<br>- ast_debug(1, "Wizard mapped for object_type '%s'\n", object_type);<br> }<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7074">change 7074</a>. To unsubscribe, 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/7074"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib5d3bcabbd9c24dd8a3c9cc692a794a5f60243ad </div>
<div style="display:none"> Gerrit-Change-Number: 7074 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>