<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9036">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">channel.c: Fix off nominal channel allocation failure path.<br><br>__ast_channel_alloc_ap() had a failure exit path that hadn't setup the fd<br>descriptors to -1 yet.  The destructor would then attempt to close these<br>fd's that had never been opened.<br><br>Change-Id: Icf21093f36c60781e8cf6ee9d586536302af33e3<br>---<br>M main/channel.c<br>1 file changed, 10 insertions(+), 9 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/36/9036/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/channel.c b/main/channel.c<br>index a23dfa1..5a54845 100644<br>--- a/main/channel.c<br>+++ b/main/channel.c<br>@@ -801,7 +801,16 @@<br> <br>    ast_channel_stage_snapshot(tmp);<br> <br>-  if (!(nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {<br>+  /*<br>+    * Init file descriptors to unopened state so<br>+         * the destructor can know not to close them.<br>+         */<br>+  ast_channel_timingfd_set(tmp, -1);<br>+   ast_channel_internal_alertpipe_clear(tmp);<br>+   ast_channel_internal_fd_clear_all(tmp);<br>+<br>+   nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);<br>+   if (!nativeformats) {<br>                 /*<br>             * Aborting the channel creation.  We do not need to complete staging<br>                  * the channel snapshot because the channel has not been finalized or<br>@@ -818,14 +827,6 @@<br>   ast_channel_set_rawreadformat(tmp, ast_format_none);<br>  ast_channel_set_writeformat(tmp, ast_format_none);<br>    ast_channel_set_readformat(tmp, ast_format_none);<br>-<br>- /*<br>-    * Init file descriptors to unopened state so<br>-         * the destructor can know not to close them.<br>-         */<br>-  ast_channel_timingfd_set(tmp, -1);<br>-   ast_channel_internal_alertpipe_clear(tmp);<br>-   ast_channel_internal_fd_clear_all(tmp);<br> <br>    if (!(schedctx = ast_sched_context_create())) {<br>               ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9036">change 9036</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/9036"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Icf21093f36c60781e8cf6ee9d586536302af33e3 </div>
<div style="display:none"> Gerrit-Change-Number: 9036 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>