From 35d44c3fec412cb7118e456aca4ff090c1b63244 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Thu, 20 Apr 2017 09:02:46 -0400 Subject: [PATCH] FS-10251 [mod_rayo] fix defects found by clang-analyzer --- src/mod/event_handlers/mod_rayo/rayo_input_component.c | 3 +++ src/mod/event_handlers/mod_rayo/rayo_output_component.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mod/event_handlers/mod_rayo/rayo_input_component.c b/src/mod/event_handlers/mod_rayo/rayo_input_component.c index 6e1feefb82..dc7a71c9d9 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_input_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_input_component.c @@ -447,6 +447,7 @@ static char *setup_grammars_pocketsphinx(struct input_component *component, swit if (!(component->grammar = srgs_parse(globals.parser, iks_find_cdata(input, "grammar")))) { *stanza_error = STANZA_ERROR_BAD_REQUEST; *error_detail = "Failed to parse grammar body"; + switch_safe_free(grammar.data); return NULL; } @@ -454,6 +455,7 @@ static char *setup_grammars_pocketsphinx(struct input_component *component, swit if (!jsgf_path) { *stanza_error = STANZA_ERROR_BAD_REQUEST; *error_detail = "Grammar conversion to JSGF error"; + switch_safe_free(grammar.data); return NULL; } @@ -483,6 +485,7 @@ static char *setup_grammars_unimrcp(struct input_component *component, switch_co switch_mutex_lock(component->handler->mutex); *stanza_error = STANZA_ERROR_INTERNAL_SERVER_ERROR; *error_detail = "Failed to initialize recognizer"; + switch_safe_free(grammar_uri_list.data); return NULL; } switch_mutex_lock(component->handler->mutex); diff --git a/src/mod/event_handlers/mod_rayo/rayo_output_component.c b/src/mod/event_handlers/mod_rayo/rayo_output_component.c index c6447cbacc..f94921fd91 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_output_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_output_component.c @@ -518,6 +518,11 @@ static switch_status_t next_file(switch_file_handle_t *handle) struct rayo_file_context *context = handle->private_info; struct output_component *output = context->component ? OUTPUT_COMPONENT(context->component) : NULL; + if (!output) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing output component!\n"); + return SWITCH_STATUS_FALSE; + } + top: if (switch_test_flag((&context->fh), SWITCH_FILE_OPEN)) { @@ -1045,8 +1050,7 @@ static switch_status_t fileman_file_read(switch_file_handle_t *handle, void *dat //switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_DEBUG, "Read file %"SWITCH_SIZE_T_FMT" bytes\n", o_len * 2); /* add file data to audio bufer */ - read_bytes = switch_buffer_write(fh->audio_buffer, context->abuf, o_len * 2); - //switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_DEBUG, "Write audio frame %"SWITCH_SIZE_T_FMT" bytes\n", read_bytes); + switch_buffer_write(fh->audio_buffer, context->abuf, o_len * 2); read_bytes = switch_buffer_read(fh->audio_buffer, context->abuf, *len * 2); o_len = read_bytes / 2; @@ -1114,7 +1118,6 @@ static switch_status_t fileman_file_read(switch_file_handle_t *handle, void *dat if (wrote_len < new_len) { switch_size_t r_len = new_len - wrote_len; switch_buffer_write(fh->sp_audio_buffer, bp, r_len * 2); - wrote_len += r_len; } continue; }