diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/cdr.c | 6 | ||||
-rw-r--r-- | main/cli.c | 27 | ||||
-rw-r--r-- | main/format_cap.c | 9 | ||||
-rw-r--r-- | main/message.c | 14 | ||||
-rw-r--r-- | main/pbx.c | 18 | ||||
-rw-r--r-- | main/stasis.c | 5 | ||||
-rw-r--r-- | main/stream.c | 3 |
7 files changed, 40 insertions, 42 deletions
diff --git a/main/cdr.c b/main/cdr.c index fdf764540..3681cdc6b 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -3407,7 +3407,8 @@ static int cdr_object_update_party_b_userfield_cb(void *obj, void *arg, void *da ast_assert(cdr->party_b.snapshot && !strcasecmp(cdr->party_b.snapshot->name, info->channel_name)); - strcpy(cdr->party_b.userfield, info->userfield); + ast_copy_string(cdr->party_b.userfield, info->userfield, + sizeof(cdr->party_b.userfield)); } return 0; @@ -3430,7 +3431,8 @@ void ast_cdr_setuserfield(const char *channel_name, const char *userfield) if (it_cdr->fn_table == &finalized_state_fn_table && it_cdr->next != NULL) { continue; } - ast_copy_string(it_cdr->party_a.userfield, userfield, AST_MAX_USER_FIELD); + ast_copy_string(it_cdr->party_a.userfield, userfield, + sizeof(it_cdr->party_a.userfield)); } ao2_unlock(cdr); } diff --git a/main/cli.c b/main/cli.c index 0896181b0..5c16e8b7a 100644 --- a/main/cli.c +++ b/main/cli.c @@ -1362,31 +1362,6 @@ static char *handle_commandnummatches(struct ast_cli_entry *e, int cmd, struct a return CLI_SUCCESS; } -static char *handle_commandcomplete(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *buf; - switch (cmd) { - case CLI_INIT: - e->command = "_command complete"; - e->usage = - "Usage: _command complete \"<line>\" text state\n" - " This function is used internally to help with command completion and should.\n" - " never be called by the user directly.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - if (a->argc != 5) - return CLI_SHOWUSAGE; - buf = __ast_cli_generator(a->argv[2], a->argv[3], atoi(a->argv[4]), 0); - if (buf) { - ast_cli(a->fd, "%s", buf); - ast_free(buf); - } else - ast_cli(a->fd, "NULL\n"); - return CLI_SUCCESS; -} - struct channel_set_debug_args { int fd; int is_off; @@ -1817,8 +1792,6 @@ static char *handle_cli_wait_fullybooted(struct ast_cli_entry *e, int cmd, struc static char *handle_help(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static struct ast_cli_entry cli_cli[] = { - /* Deprecated, but preferred command is now consolidated (and already has a deprecated command for it). */ - AST_CLI_DEFINE(handle_commandcomplete, "Command complete"), AST_CLI_DEFINE(handle_commandnummatches, "Returns number of command matches"), AST_CLI_DEFINE(handle_commandmatchesarray, "Returns command matches array"), diff --git a/main/format_cap.c b/main/format_cap.c index b0897c001..d71ccdbaa 100644 --- a/main/format_cap.c +++ b/main/format_cap.c @@ -160,13 +160,16 @@ static inline int format_cap_framed_init(struct format_cap_framed *framed, struc } list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format)); + /* This takes the allocation reference */ + if (AST_VECTOR_APPEND(&cap->preference_order, framed)) { + ao2_ref(framed, -1); + return -1; + } + /* Order doesn't matter for formats, so insert at the head for performance reasons */ ao2_ref(framed, +1); AST_LIST_INSERT_HEAD(list, framed, entry); - /* This takes the allocation reference */ - AST_VECTOR_APPEND(&cap->preference_order, framed); - cap->framing = MIN(cap->framing, framing ? framing : ast_format_get_default_ms(format)); return 0; diff --git a/main/message.c b/main/message.c index fcdf705fe..ac7965ea7 100644 --- a/main/message.c +++ b/main/message.c @@ -1362,7 +1362,12 @@ int ast_msg_tech_register(const struct ast_msg_tech *tech) return -1; } - AST_VECTOR_APPEND(&msg_techs, tech); + if (AST_VECTOR_APPEND(&msg_techs, tech)) { + ast_log(LOG_ERROR, "Failed to register message technology for '%s'\n", + tech->name); + ast_rwlock_unlock(&msg_techs_lock); + return -1; + } ast_verb(3, "Message technology '%s' registered.\n", tech->name); ast_rwlock_unlock(&msg_techs_lock); @@ -1417,7 +1422,12 @@ int ast_msg_handler_register(const struct ast_msg_handler *handler) return -1; } - AST_VECTOR_APPEND(&msg_handlers, handler); + if (AST_VECTOR_APPEND(&msg_handlers, handler)) { + ast_log(LOG_ERROR, "Failed to register message handler for '%s'\n", + handler->name); + ast_rwlock_unlock(&msg_handlers_lock); + return -1; + } ast_verb(2, "Message handler '%s' registered.\n", handler->name); ast_rwlock_unlock(&msg_handlers_lock); diff --git a/main/pbx.c b/main/pbx.c index 2366b72b0..b5602b55c 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -6692,7 +6692,11 @@ int ast_context_add_include2(struct ast_context *con, const char *value, } /* ... include new context into context list, unlock, return */ - AST_VECTOR_APPEND(&con->includes, new_include); + if (AST_VECTOR_APPEND(&con->includes, new_include)) { + include_free(new_include); + ast_unlock_context(con); + return -1; + } ast_verb(3, "Including context '%s' in context '%s'\n", ast_get_include_name(new_include), ast_get_context_name(con)); @@ -6754,7 +6758,11 @@ int ast_context_add_switch2(struct ast_context *con, const char *value, } /* ... sw new context into context list, unlock, return */ - AST_VECTOR_APPEND(&con->alts, new_sw); + if (AST_VECTOR_APPEND(&con->alts, new_sw)) { + sw_free(new_sw); + ast_unlock_context(con); + return -1; + } ast_verb(3, "Including switch '%s/%s' in context '%s'\n", ast_get_switch_name(new_sw), ast_get_switch_data(new_sw), ast_get_context_name(con)); @@ -6842,7 +6850,11 @@ int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const return -1; } } - AST_VECTOR_APPEND(&con->ignorepats, ignorepat); + if (AST_VECTOR_APPEND(&con->ignorepats, ignorepat)) { + ignorepat_free(ignorepat); + ast_unlock_context(con); + return -1; + } ast_unlock_context(con); return 0; diff --git a/main/stasis.c b/main/stasis.c index 4a5d8ac7c..186d88fdd 100644 --- a/main/stasis.c +++ b/main/stasis.c @@ -1240,10 +1240,9 @@ struct ast_multi_object_blob *ast_multi_object_blob_create(struct ast_json *blob void ast_multi_object_blob_add(struct ast_multi_object_blob *multi, enum stasis_user_multi_object_snapshot_type type, void *object) { - if (!multi || !object) { - return; + if (!multi || !object || AST_VECTOR_APPEND(&multi->snapshots[type], object)) { + ao2_cleanup(object); } - AST_VECTOR_APPEND(&multi->snapshots[type],object); } /*! \brief Publish single channel user event (for app_userevent compatibility) */ diff --git a/main/stream.c b/main/stream.c index 72d859954..8597485f7 100644 --- a/main/stream.c +++ b/main/stream.c @@ -398,8 +398,7 @@ int ast_stream_topology_set_stream(struct ast_stream_topology *topology, stream->position = position; if (position == AST_VECTOR_SIZE(&topology->streams)) { - AST_VECTOR_APPEND(&topology->streams, stream); - return 0; + return AST_VECTOR_APPEND(&topology->streams, stream); } return AST_VECTOR_REPLACE(&topology->streams, position, stream); |