<p>Richard Mudgett <strong>posted comments</strong> on this change.</p><p><a href="https://gerrit.asterisk.org/5809">View Change</a></p><p>Patch set 2:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4;">Code-Review -1</span></p><p>(1 comment)</p><ul style="list-style: none; padding-left: 20px;"><li><p><a href="https://gerrit.asterisk.org/#/c/5809/2/rest-api-templates/res_ari_resource.c.mustache">File rest-api-templates/res_ari_resource.c.mustache:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/5809/2/rest-api-templates/res_ari_resource.c.mustache@265">Patch Set #2, Line 265:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">{{#apis}}<br>{{#operations}}<br>{{#has_websocket}}<br> struct ast_websocket_protocol *protocol;<br><br> {{full_name}}.ws_server = ast_websocket_server_create();<br> if (!{{full_name}}.ws_server) {<br> return AST_MODULE_LOAD_DECLINE;<br> }<br><br> protocol = ast_websocket_sub_protocol_alloc("{{websocket_protocol}}");<br> if (!protocol) {<br> ao2_ref({{full_name}}.ws_server, -1);<br> {{full_name}}.ws_server = NULL;<br> return AST_MODULE_LOAD_DECLINE;<br> }<br> protocol->session_attempted = ast_ari_{{c_name}}_{{c_nickname}}_ws_attempted_cb;<br> protocol->session_established = ast_ari_{{c_name}}_{{c_nickname}}_ws_established_cb;<br>{{/has_websocket}}<br>{{#is_websocket}}<br> res |= ast_websocket_server_add_protocol2({{full_name}}.ws_server, protocol);<br>{{/is_websocket}}<br>{{/operations}}<br>{{/apis}}<br><br> CHECK_ARI_MODULE_LOADED();<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">{full_name}.ws_server<br>is leaked if CHECK_ARI_MODULE_LOADED() declines the load.</p><p style="white-space: pre-wrap; word-wrap: break-word;">To fix probably have to move CHECK_ARI_MODULE_LOADED() to right after res is declared. Since protocol is declared after that, some blocking curly braces are needed inside the #operations block so we don't violate the variables must be declared at the start of a block requirement:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> int res = 0;</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> CHECK_ARI_MODULE_LOADED();</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">{{#apis}}<br>{{#operations}}<br> {<br>... surrounded code indented by another level.<br> }<br>{{/operations}}<br>{{/apis}}</pre></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/5809">change 5809</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/5809"/><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-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: I263d56efa628ee3c411bdcd16d49af6260c6c91d </div>
<div style="display:none"> Gerrit-Change-Number: 5809 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Tue, 13 Jun 2017 18:33:27 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>