From 37d2a34b04682c6be0653b955386886836199d4a Mon Sep 17 00:00:00 2001
From: William King <william.king@quentustech.com>
Date: Fri, 25 Jan 2013 11:41:57 -0800
Subject: [PATCH] Don't try to get the channel if the session is null.

---
 src/mod/endpoints/mod_rtmp/mod_rtmp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.c b/src/mod/endpoints/mod_rtmp/mod_rtmp.c
index 164491a70b..9f36a41745 100644
--- a/src/mod/endpoints/mod_rtmp/mod_rtmp.c
+++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.c
@@ -805,8 +805,10 @@ switch_status_t rtmp_session_destroy(rtmp_session_t **session)
 		switch_hash_this(hi, &key, &keylen, &val);		
 		item = (rtmp_private_t *)val;
 		
-		channel = switch_core_session_get_channel(item->session);
-		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		if ( item->session ) {
+			channel = switch_core_session_get_channel(item->session);
+			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		}
 	}
 	switch_thread_rwlock_unlock((*session)->session_rwlock);