]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
asr result in mrcp message body must be checked to exist before use
authorArsen Chaloyan <achaloyan@yahoo.com>
Mon, 20 Aug 2007 18:10:00 +0000 (18:10 +0000)
committerArsen Chaloyan <achaloyan@yahoo.com>
Mon, 20 Aug 2007 18:10:00 +0000 (18:10 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5633 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c

index 53d3f8fec42de7a853fd46f63c4cbdddea039dc2..764cb1c721894702caa8cc4f5bb2bfc8f542f9a7 100644 (file)
@@ -487,15 +487,21 @@ static switch_status_t openmrcp_asr_get_results(switch_asr_handle_t *ah, char **
           </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