[Asterisk-code-review] channel.c: Fix off nominal channel allocation failure path. (asterisk[15])
Joshua Colp
asteriskteam at digium.com
Thu May 24 05:18:05 CDT 2018
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9035 )
Change subject: channel.c: Fix off nominal channel allocation failure path.
......................................................................
channel.c: Fix off nominal channel allocation failure path.
__ast_channel_alloc_ap() had a failure exit path that hadn't setup the fd
descriptors to -1 yet. The destructor would then attempt to close these
fd's that had never been opened.
Change-Id: Icf21093f36c60781e8cf6ee9d586536302af33e3
---
M main/channel.c
1 file changed, 10 insertions(+), 9 deletions(-)
Approvals:
Matthew Fredrickson: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
diff --git a/main/channel.c b/main/channel.c
index 861166f..4475d24 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -813,7 +813,16 @@
ast_channel_stage_snapshot(tmp);
- if (!(nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
+ /*
+ * Init file descriptors to unopened state so
+ * the destructor can know not to close them.
+ */
+ ast_channel_timingfd_set(tmp, -1);
+ ast_channel_internal_alertpipe_clear(tmp);
+ ast_channel_internal_fd_clear_all(tmp);
+
+ nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ if (!nativeformats) {
/*
* Aborting the channel creation. We do not need to complete staging
* the channel snapshot because the channel has not been finalized or
@@ -830,14 +839,6 @@
ast_channel_set_rawreadformat(tmp, ast_format_none);
ast_channel_set_writeformat(tmp, ast_format_none);
ast_channel_set_readformat(tmp, ast_format_none);
-
- /*
- * Init file descriptors to unopened state so
- * the destructor can know not to close them.
- */
- ast_channel_timingfd_set(tmp, -1);
- ast_channel_internal_alertpipe_clear(tmp);
- ast_channel_internal_fd_clear_all(tmp);
if (!(schedctx = ast_sched_context_create())) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
--
To view, visit https://gerrit.asterisk.org/9035
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: Icf21093f36c60781e8cf6ee9d586536302af33e3
Gerrit-Change-Number: 9035
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180524/4e4094e8/attachment-0001.html>
More information about the asterisk-code-review
mailing list