]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10251 [mod_rayo] fix defects found by clang-analyzer
authorChris Rienzo <chris.rienzo@logmein.com>
Thu, 20 Apr 2017 13:02:46 +0000 (09:02 -0400)
committerChris Rienzo <chris.rienzo@logmein.com>
Thu, 20 Apr 2017 13:02:46 +0000 (09:02 -0400)
src/mod/event_handlers/mod_rayo/rayo_input_component.c
src/mod/event_handlers/mod_rayo/rayo_output_component.c

index 6e1feefb825747b45007f2e0af42364ce7a9d50f..dc7a71c9d9e85b5bb3ace0dfb890d4fdbe27c219 100644 (file)
@@ -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);
index c6447cbacc6c8dc886e3687c79ce4bae1b8d4c07..f94921fd91a17be774ae76d645257afa8e13b2ad 100644 (file)
@@ -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;
                }