<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14981">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Joshua Colp: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_session: Fix stream name memory leak.<br><br>When constructing a stream name based on the media type<br>and position the allocated name was not being freed<br>causing a leak.<br><br>Change-Id: I52510863b24a2f531f0a55b440bb2c81844029de<br>---<br>M res/res_pjsip_session.c<br>1 file changed, 4 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index cd31aca..42edaf6 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -803,7 +803,7 @@</span><br><span>            }</span><br><span>            if (!stream) {</span><br><span>                       struct ast_stream *existing_stream = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-                      char *stream_name = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+                     char *stream_name = NULL, *stream_name_allocated = NULL;</span><br><span>                     const char *stream_label = NULL;</span><br><span> </span><br><span>                         if (session->active_media_state->topology &&</span><br><span>@@ -819,17 +819,19 @@</span><br><span>                   }</span><br><span> </span><br><span>                        if (ast_strlen_zero(stream_name)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                             if (ast_asprintf(&stream_name, "%s-%d", ast_codec_media_type2str(type), i) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                            if (ast_asprintf(&stream_name_allocated, "%s-%d", ast_codec_media_type2str(type), i) < 0) {</span><br><span>                                         handled = 0;</span><br><span>                                         SCOPE_EXIT_LOG_EXPR(goto end, LOG_ERROR, "%s: Couldn't alloc stream name\n",</span><br><span>                                            ast_sip_session_get_name(session));</span><br><span> </span><br><span>                             }</span><br><span style="color: hsl(120, 100%, 40%);">+                             stream_name = stream_name_allocated;</span><br><span>                                 ast_trace(-1, "%s: Using %s for new stream name\n", ast_sip_session_get_name(session),</span><br><span>                                     stream_name);</span><br><span>                        }</span><br><span> </span><br><span>                        stream = ast_stream_alloc(stream_name, type);</span><br><span style="color: hsl(120, 100%, 40%);">+                 ast_free(stream_name_allocated);</span><br><span>                     if (!stream) {</span><br><span>                               handled = 0;</span><br><span>                                 SCOPE_EXIT_LOG_EXPR(goto end, LOG_ERROR, "%s: Couldn't alloc stream\n",</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14981">change 14981</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/+/14981"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I52510863b24a2f531f0a55b440bb2c81844029de </div>
<div style="display:none"> Gerrit-Change-Number: 14981 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>