[Freeswitch-svn] [commit] r5633 - freeswitch/trunk/src/mod/asr_tts/mod_openmrcp

Freeswitch SVN achaloyan at freeswitch.org
Mon Aug 20 14:10:01 EDT 2007


Author: achaloyan
Date: Mon Aug 20 14:10:00 2007
New Revision: 5633

Modified:
   freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c

Log:
asr result in mrcp message body must be checked to exist before use

Modified: freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c	(original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c	Mon Aug 20 14:10:00 2007
@@ -487,15 +487,21 @@
           </result>
 		*/
 
-		char *marker = "?>";  // FIXME -- lame and brittle way of doing this.  use regex or better.
-		char *position = strstr(asr_session->mrcp_message_last_rcvd->body, marker);
-		if (!position) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad result received from mrcp server: %s", asr_session->mrcp_message_last_rcvd->body);
-			ret = SWITCH_STATUS_FALSE;
+		if(asr_session->mrcp_message_last_rcvd && asr_session->mrcp_message_last_rcvd->body) {
+			char *marker = "?>";  // FIXME -- lame and brittle way of doing this.  use regex or better.
+			char *position = strstr(asr_session->mrcp_message_last_rcvd->body, marker);
+			if (!position) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad result received from mrcp server: %s", asr_session->mrcp_message_last_rcvd->body);
+				ret = SWITCH_STATUS_FALSE;
+			}
+			else {
+				position += strlen(marker);
+				*xmlstr = strdup(position);
+			}
 		}
 		else {
-			position += strlen(marker);
-			*xmlstr = strdup(position);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No result received from mrcp server: %s");
+			ret = SWITCH_STATUS_FALSE;
 		}
 
 		// since we are returning our result here, future calls to check_results



More information about the Freeswitch-svn mailing list