summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/db.c8
-rw-r--r--main/format_cap.c9
-rw-r--r--main/json.c2
-rw-r--r--main/pbx.c18
-rw-r--r--main/rtp_engine.c24
-rw-r--r--main/stasis.c14
-rw-r--r--main/stasis_channels.c4
-rw-r--r--main/tcptls.c5
-rw-r--r--main/utils.c8
9 files changed, 65 insertions, 27 deletions
diff --git a/main/db.c b/main/db.c
index 94324355f..fa125d749 100644
--- a/main/db.c
+++ b/main/db.c
@@ -191,9 +191,11 @@ static int convert_bdb_to_sqlite3(void)
char *cmd;
int res;
- ast_asprintf(&cmd, "%s/astdb2sqlite3 '%s'\n", ast_config_AST_SBIN_DIR, ast_config_AST_DB);
- res = ast_safe_system(cmd);
- ast_free(cmd);
+ res = ast_asprintf(&cmd, "%s/astdb2sqlite3 '%s'\n", ast_config_AST_SBIN_DIR, ast_config_AST_DB);
+ if (0 <= res) {
+ res = ast_safe_system(cmd);
+ ast_free(cmd);
+ }
return res;
}
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/json.c b/main/json.c
index 9004978b4..56df7f401 100644
--- a/main/json.c
+++ b/main/json.c
@@ -460,7 +460,7 @@ struct ast_json *ast_json_vstringf(const char *format, va_list args)
if (format) {
int err = ast_vasprintf(&str, format, args);
- if (err > 0) {
+ if (err >= 0) {
ret = json_string(str);
ast_free(str);
}
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/rtp_engine.c b/main/rtp_engine.c
index 0aed8e97c..2431ffc0c 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -802,7 +802,10 @@ static void rtp_codecs_payload_replace_rx(struct ast_rtp_codecs *codecs, int pay
ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_rx, payload),
"cleaning up rx mapping vector element about to be replaced");
}
- AST_VECTOR_REPLACE(&codecs->payload_mapping_rx, payload, new_type);
+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_rx, payload, new_type)) {
+ ao2_ref(new_type, -1);
+ return;
+ }
payload_mapping_rx_clear_primary(codecs, new_type);
}
@@ -924,7 +927,10 @@ static void rtp_codecs_payloads_copy_tx(struct ast_rtp_codecs *src, struct ast_r
ao2_t_cleanup(AST_VECTOR_GET(&dest->payload_mapping_tx, idx),
"cleaning up tx mapping vector element about to be replaced");
}
- AST_VECTOR_REPLACE(&dest->payload_mapping_tx, idx, type);
+ if (AST_VECTOR_REPLACE(&dest->payload_mapping_tx, idx, type)) {
+ ao2_ref(type, -1);
+ continue;
+ }
if (instance && instance->engine && instance->engine->payload_set) {
ao2_lock(instance);
@@ -1038,9 +1044,10 @@ void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct as
ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload),
"cleaning up replaced tx payload type");
}
- AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type);
- if (instance && instance->engine && instance->engine->payload_set) {
+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type)) {
+ ao2_ref(new_type, -1);
+ } else if (instance && instance->engine && instance->engine->payload_set) {
ao2_lock(instance);
instance->engine->payload_set(instance, payload, new_type->asterisk_format, new_type->format, new_type->rtp_code);
ao2_unlock(instance);
@@ -1116,9 +1123,10 @@ int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs,
ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, pt),
"cleaning up replaced tx payload type");
}
- AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type);
- if (instance && instance->engine && instance->engine->payload_set) {
+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type)) {
+ ao2_ref(new_type, -1);
+ } else if (instance && instance->engine && instance->engine->payload_set) {
ao2_lock(instance);
instance->engine->payload_set(instance, pt, new_type->asterisk_format, new_type->format, new_type->rtp_code);
ao2_unlock(instance);
@@ -1215,7 +1223,9 @@ int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int pay
if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
ao2_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload));
}
- AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type);
+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type)) {
+ ao2_ref(type, -1);
+ }
} else {
ao2_ref(type, -1);
}
diff --git a/main/stasis.c b/main/stasis.c
index a82e938f4..4a5d8ac7c 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -908,7 +908,7 @@ struct stasis_forward *stasis_forward_all(struct stasis_topic *from_topic,
{
int res;
size_t idx;
- RAII_VAR(struct stasis_forward *, forward, NULL, ao2_cleanup);
+ struct stasis_forward *forward;
if (!from_topic || !to_topic) {
return NULL;
@@ -921,7 +921,7 @@ struct stasis_forward *stasis_forward_all(struct stasis_topic *from_topic,
/* Forwards to ourselves are implicit. */
if (to_topic == from_topic) {
- return ao2_bump(forward);
+ return forward;
}
forward->from_topic = ao2_bump(from_topic);
@@ -932,6 +932,7 @@ struct stasis_forward *stasis_forward_all(struct stasis_topic *from_topic,
if (res != 0) {
ao2_unlock(from_topic);
ao2_unlock(to_topic);
+ ao2_ref(forward, -1);
return NULL;
}
@@ -941,7 +942,7 @@ struct stasis_forward *stasis_forward_all(struct stasis_topic *from_topic,
ao2_unlock(from_topic);
ao2_unlock(to_topic);
- return ao2_bump(forward);
+ return forward;
}
static void subscription_change_dtor(void *obj)
@@ -1342,7 +1343,7 @@ static struct ast_str *multi_object_blob_to_ami(void *obj)
for (type = 0; type < STASIS_UMOS_MAX; ++type) {
for (i = 0; i < AST_VECTOR_SIZE(&multi->snapshots[type]); ++i) {
- char *name = "";
+ char *name = NULL;
void *snapshot = AST_VECTOR_GET(&multi->snapshots[type], i);
ami_snapshot = NULL;
@@ -1352,11 +1353,11 @@ static struct ast_str *multi_object_blob_to_ami(void *obj)
switch (type) {
case STASIS_UMOS_CHANNEL:
- ami_snapshot = ast_manager_build_channel_state_string_prefix(snapshot, name);
+ ami_snapshot = ast_manager_build_channel_state_string_prefix(snapshot, name ?: "");
break;
case STASIS_UMOS_BRIDGE:
- ami_snapshot = ast_manager_build_bridge_state_string_prefix(snapshot, name);
+ ami_snapshot = ast_manager_build_bridge_state_string_prefix(snapshot, name ?: "");
break;
case STASIS_UMOS_ENDPOINT:
@@ -1367,6 +1368,7 @@ static struct ast_str *multi_object_blob_to_ami(void *obj)
ast_str_append(&ami_str, 0, "%s", ast_str_buffer(ami_snapshot));
ast_free(ami_snapshot);
}
+ ast_free(name);
}
}
diff --git a/main/stasis_channels.c b/main/stasis_channels.c
index dd71b8651..b81dbe599 100644
--- a/main/stasis_channels.c
+++ b/main/stasis_channels.c
@@ -891,7 +891,7 @@ struct ast_json *ast_channel_snapshot_to_json(
const struct ast_channel_snapshot *snapshot,
const struct stasis_message_sanitizer *sanitize)
{
- RAII_VAR(struct ast_json *, json_chan, NULL, ast_json_unref);
+ struct ast_json *json_chan;
if (snapshot == NULL
|| (sanitize && sanitize->channel_snapshot
@@ -924,7 +924,7 @@ struct ast_json *ast_channel_snapshot_to_json(
ast_json_object_set(json_chan, "channelvars", ast_json_channel_vars(snapshot->ari_vars));
}
- return ast_json_ref(json_chan);
+ return json_chan;
}
int ast_channel_snapshot_cep_equal(
diff --git a/main/tcptls.c b/main/tcptls.c
index 4a95f72ef..a6d0538af 100644
--- a/main/tcptls.c
+++ b/main/tcptls.c
@@ -316,7 +316,10 @@ static void __ssl_setup_certs(struct ast_tls_config *cfg, const size_t cert_file
static int __ssl_setup(struct ast_tls_config *cfg, int client)
{
#ifndef DO_SSL
- cfg->enabled = 0;
+ if (cfg->enabled) {
+ ast_log(LOG_NOTICE, "Configured without OpenSSL Development Headers");
+ cfg->enabled = 0;
+ }
return 0;
#else
int disable_ssl = 0;
diff --git a/main/utils.c b/main/utils.c
index f20ccd36e..dd7176295 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -2349,7 +2349,13 @@ int __ast_asprintf(const char *file, int lineno, const char *func, char **ret, c
va_list ap;
va_start(ap, fmt);
- if ((res = vasprintf(ret, fmt, ap)) == -1) {
+ res = vasprintf(ret, fmt, ap);
+ if (res < 0) {
+ /*
+ * *ret is undefined so set to NULL to ensure it is
+ * initialized to something useful.
+ */
+ *ret = NULL;
MALLOC_FAILURE_MSG;
}
va_end(ap);