From bf6bddcc7963f3aacc223108b36dc650149246bb Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Wed, 13 Aug 2014 13:08:39 -0500 Subject: [PATCH] channels: Do not crash if NULL channel passed to ast_channel_uniqueid(). Fixes a crash I was experiencing when meetme conferences were shutdown, due to ast_channel_uniqueid() being called with a NULL pointer. From http://svn.asterisk.org/svn/asterisk/branches/13@420940: #0 in ast_channel_uniqueid (chan=0x0) at channel_internal_api.c:489 #1 in meetme_stasis_generate_msg (meetme_conference=0xb724b5e8, chan=0x0, user=0x0, message_type=0x85a6afc, extras=0x0) at app_meetme.c:1383 #2 in conf_free (conf=0xb724b5e8) at app_meetme.c:2326 #3 in dispose_conf (conf=0xb724b5e8) at app_meetme.c:2503 #4 in conf_exec (chan=0xb7ef50ec, data=0xb738cbe8 "1337,i") at app_meetme.c:5138 #5 in pbx_exec (c=0xb7ef50ec, app=0x85a7d38, data=0xb738cbe8 "1337,i") at pbx.c:1658 #6 in pbx_extension_helper (c=0xb7ef50ec, con=0x0, context=0xb7ef5774 "phones", exten=0xb7ef57c4 "1337", priority=5, label=0x0, callerid=0xb7e759c8 "6001", action=E_SPAWN, found=0xb738f060, combined_find_spawn=1) at pbx.c:4930 #7 in ast_spawn_extension (c=0xb7ef50ec, context=0xb7ef5774 "phones", exten=0xb7ef57c4 "1337", priority=5, callerid=0xb7e759c8 "6001", found=0xb738f060, combined_find_spawn=1) at pbx.c:5945 ... --- main/channel_internal_api.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c index e32a527..1cb91fb 100644 --- a/main/channel_internal_api.c +++ b/main/channel_internal_api.c @@ -487,8 +487,12 @@ DEFINE_STRINGFIELD_GETTER_FOR(dialcontext); const char *ast_channel_uniqueid(const struct ast_channel *chan) { - ast_assert(chan->uniqueid.unique_id[0] != '\0'); - return chan->uniqueid.unique_id; + if (chan) { + ast_assert(chan->uniqueid.unique_id[0] != '\0'); + return chan->uniqueid.unique_id; + } else { + return "NULLCHANNEL"; + } } const char *ast_channel_linkedid(const struct ast_channel *chan) -- 1.8.3.4