[Asterisk-code-review] res_stasis_snoop: Fix snoop crash (asterisk[master])

Friendly Automation asteriskteam at digium.com
Mon Jan 30 08:28:34 CST 2023


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19781 )

Change subject: res_stasis_snoop: Fix snoop crash
......................................................................

res_stasis_snoop: Fix snoop crash

Added NULL pointer check and channel lock to prevent resource release
while the chanspy is processing.

ASTERISK-29604

Change-Id: Ibdc675f98052da32333b19685b1708a3751b6d24
---
M res/res_stasis_snoop.c
1 file changed, 21 insertions(+), 3 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  N A: Looks good to me, but someone else must approve
  Friendly Automation: Approved for Submit




diff --git a/res/res_stasis_snoop.c b/res/res_stasis_snoop.c
index 70cdd7c..12964cc 100644
--- a/res/res_stasis_snoop.c
+++ b/res/res_stasis_snoop.c
@@ -135,9 +135,13 @@
 	}
 	ast_multi_channel_blob_add_channel(payload, "spyer_channel", snoop_snapshot);
 
-	spyee_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(snoop->spyee_chan));
-	if (spyee_snapshot) {
-		ast_multi_channel_blob_add_channel(payload, "spyee_channel", spyee_snapshot);
+	if (snoop->spyee_chan) {
+		ast_channel_lock(snoop->spyee_chan);
+		spyee_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(snoop->spyee_chan));
+		ast_channel_unlock(snoop->spyee_chan);
+		if (spyee_snapshot) {
+			ast_multi_channel_blob_add_channel(payload, "spyee_channel", spyee_snapshot);
+		}
 	}
 
 	message = stasis_message_create(type, payload);

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ibdc675f98052da32333b19685b1708a3751b6d24
Gerrit-Change-Number: 19781
Gerrit-PatchSet: 5
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: N A <asterisk at phreaknet.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230130/89b41adb/attachment.html>


More information about the asterisk-code-review mailing list