From 0f17bcc5b6fa5a8c592f1bb77282a48d26207bad Mon Sep 17 00:00:00 2001
From: Luke Dashjr <luke@openmethods.com>
Date: Thu, 17 Mar 2011 15:31:07 -0500
Subject: [PATCH] Bugfix: Destroy schannel only *after* cleanup of its contents
 is done

---
 src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
index b3679cf516..63264a0049 100644
--- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
+++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
@@ -3120,12 +3120,12 @@ static switch_status_t recog_asr_close(switch_asr_handle_t *ah, switch_asr_flag_
 	speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
 	recognizer_data_t *r = (recognizer_data_t *) schannel->data;
 	speech_channel_stop(schannel);
-	speech_channel_destroy(schannel);
 	switch_core_hash_destroy(&r->grammars);
 	switch_core_hash_destroy(&r->enabled_grammars);
 	if (r->dtmf_generator) {
 		mpf_dtmf_generator_destroy(r->dtmf_generator);
 	}
+	speech_channel_destroy(schannel);
 
 	/* this lets FreeSWITCH's speech_thread know the handle is closed */
 	switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED);