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

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5633 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Arsen Chaloyan 2007-08-20 18:10:00 +00:00
parent f094dc4e71
commit a56dba7f8a

View File

@ -487,15 +487,21 @@ static switch_status_t openmrcp_asr_get_results(switch_asr_handle_t *ah, char **
</result> </result>
*/ */
char *marker = "?>"; // FIXME -- lame and brittle way of doing this. use regex or better. if(asr_session->mrcp_message_last_rcvd && asr_session->mrcp_message_last_rcvd->body) {
char *position = strstr(asr_session->mrcp_message_last_rcvd->body, marker); char *marker = "?>"; // FIXME -- lame and brittle way of doing this. use regex or better.
if (!position) { char *position = strstr(asr_session->mrcp_message_last_rcvd->body, marker);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad result received from mrcp server: %s", asr_session->mrcp_message_last_rcvd->body); if (!position) {
ret = SWITCH_STATUS_FALSE; 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 { else {
position += strlen(marker); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No result received from mrcp server: %s");
*xmlstr = strdup(position); ret = SWITCH_STATUS_FALSE;
} }
// since we are returning our result here, future calls to check_results // since we are returning our result here, future calls to check_results