[Asterisk-code-review] app_queue: fix ring_entry to access nativeformats with a channel lock (...asterisk[16])

Gergely Dömsödi asteriskteam at digium.com
Wed Mar 6 07:26:29 CST 2019


Gergely Dömsödi has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/11098


Change subject: app_queue: fix ring_entry to access nativeformats with a channel lock
......................................................................

app_queue: fix ring_entry to access nativeformats with a channel lock

Fixes an intermittent segmentation fault which occured when accessing
nativeformats of a channel which entered into a queue.

ASTERISK-27964
Reported by: Francisco Seratti

Change-Id: Ic87fa7a363f3b487c24ce07032f4b2201c22db9e
---
M apps/app_queue.c
1 file changed, 7 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/98/11098/1

diff --git a/apps/app_queue.c b/apps/app_queue.c
index f441e35..132621d 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -4497,6 +4497,7 @@
 	char tech[256];
 	char *location;
 	const char *macrocontext, *macroexten;
+	struct ast_format_cap *nativeformats;
 	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
 
 	/* on entry here, we know that tmp->chan == NULL */
@@ -4513,8 +4514,13 @@
 		location = "";
 	}
 
+	ast_channel_lock(qe->chan);
+	nativeformats = ao2_bump(ast_channel_nativeformats(qe->chan));
+	ast_channel_unlock(qe->chan);
+
 	/* Request the peer */
-	tmp->chan = ast_request(tech, ast_channel_nativeformats(qe->chan), NULL, qe->chan, location, &status);
+	tmp->chan = ast_request(tech, nativeformats, NULL, qe->chan, location, &status);
+	ao2_cleanup(nativeformats);
 	if (!tmp->chan) {			/* If we can't, just go on to the next call */
 		ao2_lock(qe->parent);
 		qe->parent->rrpos++;

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11098
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ic87fa7a363f3b487c24ce07032f4b2201c22db9e
Gerrit-Change-Number: 11098
Gerrit-PatchSet: 1
Gerrit-Owner: Gergely Dömsödi <doome at uhusystems.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190306/c924e64e/attachment.html>


More information about the asterisk-code-review mailing list