summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/app_mixmonitor.c1
-rw-r--r--bridges/bridge_builtin_features.c1
-rw-r--r--channels/chan_iax2.c2
-rw-r--r--channels/chan_rtp.c1
-rw-r--r--funcs/func_aes.c2
-rw-r--r--funcs/func_periodic_hook.c5
-rw-r--r--main/Makefile2
-rw-r--r--main/aoc.c2
-rw-r--r--main/sorcery.c1
-rw-r--r--pbx/pbx_dundi.c2
-rw-r--r--res/ari/resource_asterisk.c7
-rw-r--r--res/ari/resource_events.c5
-rw-r--r--res/ari/resource_sounds.c1
-rw-r--r--res/res_agi.c5
-rw-r--r--res/res_ari.c5
-rw-r--r--res/res_http_websocket.c3
-rw-r--r--res/res_monitor.c4
-rw-r--r--res/res_pjsip.c1
-rw-r--r--res/res_pjsip_outbound_publish.c1
-rw-r--r--res/res_pjsip_outbound_registration.c1
-rw-r--r--res/res_pjsip_publish_asterisk.c1
-rw-r--r--res/res_pktccops.c4
-rw-r--r--res/res_smdi.c4
-rw-r--r--res/res_stasis_device_state.c20
-rw-r--r--res/res_stasis_mailbox.c1
-rw-r--r--res/res_statsd.c3
-rw-r--r--res/stasis/messaging.c4
-rw-r--r--tests/test_utils.c2
28 files changed, 74 insertions, 17 deletions
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index ac4564205..2922e0cd3 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -34,6 +34,7 @@
*/
/*** MODULEINFO
+ <use type="module">func_periodic_hook</use>
<support_level>core</support_level>
***/
diff --git a/bridges/bridge_builtin_features.c b/bridges/bridge_builtin_features.c
index 332857347..e6cacbf7e 100644
--- a/bridges/bridge_builtin_features.c
+++ b/bridges/bridge_builtin_features.c
@@ -26,6 +26,7 @@
*/
/*** MODULEINFO
+ <use type="module">res_monitor</use>
<support_level>core</support_level>
***/
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 04aa228bf..69261f35a 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -52,7 +52,7 @@
*/
/*** MODULEINFO
- <use type="external">crypto</use>
+ <use type="module">res_crypto</use>
<support_level>core</support_level>
***/
diff --git a/channels/chan_rtp.c b/channels/chan_rtp.c
index e1c29a2ac..0a59e330e 100644
--- a/channels/chan_rtp.c
+++ b/channels/chan_rtp.c
@@ -28,6 +28,7 @@
*/
/*** MODULEINFO
+ <depend>res_rtp_multicast</depend>
<support_level>core</support_level>
***/
diff --git a/funcs/func_aes.c b/funcs/func_aes.c
index 9392a1c7d..7208cd4c8 100644
--- a/funcs/func_aes.c
+++ b/funcs/func_aes.c
@@ -23,7 +23,7 @@
*/
/*** MODULEINFO
- <use type="external">crypto</use>
+ <use type="module">res_crypto</use>
<support_level>core</support_level>
***/
diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c
index f8e79b326..0ab3d6b8b 100644
--- a/funcs/func_periodic_hook.c
+++ b/funcs/func_periodic_hook.c
@@ -488,6 +488,11 @@ static int load_module(void)
res = ast_custom_function_register_escalating(&hook_function, AST_CFE_BOTH);
+ if (!res) {
+ /* For Optional API. */
+ ast_module_shutdown_ref(AST_MODULE_SELF);
+ }
+
return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
}
diff --git a/main/Makefile b/main/Makefile
index 968f74658..08d1f6558 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -149,7 +149,7 @@ endif
db.o: _ASTCFLAGS+=$(SQLITE3_INCLUDE)
asterisk.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
-cli.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
+loader.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
json.o: _ASTCFLAGS+=$(JANSSON_INCLUDE)
bucket.o: _ASTCFLAGS+=$(URIPARSER_INCLUDE)
crypt.o: _ASTCFLAGS+=$(CRYPT_INCLUDE)
diff --git a/main/aoc.c b/main/aoc.c
index d4b74ec92..451b21973 100644
--- a/main/aoc.c
+++ b/main/aoc.c
@@ -1713,7 +1713,7 @@ static struct ast_json *s_to_json(const struct ast_aoc_decoded *decoded)
}
for (i = 0; i < decoded->aoc_s_count; ++i) {
- struct ast_json *rate = ast_json_object_create();
+ struct ast_json *rate;
RAII_VAR(struct ast_json *, type, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, currency, NULL, ast_json_unref);
const char *charge_item = aoc_charged_item_str(
diff --git a/main/sorcery.c b/main/sorcery.c
index 61628fbf4..5ff1d106c 100644
--- a/main/sorcery.c
+++ b/main/sorcery.c
@@ -1633,6 +1633,7 @@ struct ast_json *ast_sorcery_objectset_json_create(const struct ast_sorcery *sor
int res = 0;
if (!object_type || !json) {
+ ast_json_unref(json);
return NULL;
}
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 58086aa81..b39cd7b2d 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -32,7 +32,7 @@
/*** MODULEINFO
<depend>zlib</depend>
- <use type="external">crypto</use>
+ <use type="module">res_crypto</use>
<support_level>extended</support_level>
***/
diff --git a/res/ari/resource_asterisk.c b/res/ari/resource_asterisk.c
index e76eb02bc..5c6a35af6 100644
--- a/res/ari/resource_asterisk.c
+++ b/res/ari/resource_asterisk.c
@@ -433,6 +433,10 @@ void ast_ari_asterisk_list_modules(struct ast_variable *headers,
struct ast_json *json;
json = ast_json_array_create();
+ if (!json) {
+ ast_ari_response_alloc_failed(response);
+ return;
+ }
ast_update_module_list_data(&process_module_list, NULL, json);
ast_ari_response_ok(response, json);
@@ -505,6 +509,7 @@ void ast_ari_asterisk_get_module(struct ast_variable *headers,
ast_ari_response_error(
response, 409, "Conflict",
"Module information could not be retrieved");
+ ast_json_unref(json);
return;
}
@@ -667,10 +672,12 @@ void ast_ari_asterisk_list_log_channels(struct ast_variable *headers,
if (res == AST_LOGGER_FAILURE) {
ast_ari_response_error(response, 500, "Internal Server Error",
"Response body is not valid");
+ ast_json_unref(json);
return;
} else if (res == AST_LOGGER_ALLOC_ERROR) {
ast_ari_response_error(response, 500, "Internal Server Error",
"Allocation Failed");
+ ast_json_unref(json);
return;
}
diff --git a/res/ari/resource_events.c b/res/ari/resource_events.c
index ed936f732..4be5d0223 100644
--- a/res/ari/resource_events.c
+++ b/res/ari/resource_events.c
@@ -23,6 +23,11 @@
* \author David M. Lee, II <dlee@digium.com>
*/
+/*** MODULEINFO
+ <depend type="module">res_http_websocket</depend>
+ <support_level>core</support_level>
+ ***/
+
#include "asterisk.h"
#include "resource_events.h"
diff --git a/res/ari/resource_sounds.c b/res/ari/resource_sounds.c
index 59ace5d81..2cb35b620 100644
--- a/res/ari/resource_sounds.c
+++ b/res/ari/resource_sounds.c
@@ -202,6 +202,7 @@ void ast_ari_sounds_list(struct ast_variable *headers,
if (!ast_json_array_size(sounds_blob)) {
ast_ari_response_error(response, 404, "Not Found", "No sounds found that matched the query");
+ ast_json_unref(sounds_blob);
return;
}
diff --git a/res/res_agi.c b/res/res_agi.c
index 466063557..13af48f49 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -25,6 +25,7 @@
*/
/*** MODULEINFO
+ <depend>res_speech</depend>
<support_level>core</support_level>
***/
@@ -4713,6 +4714,10 @@ static int load_module(void)
unload_module();
return AST_MODULE_LOAD_DECLINE;
}
+
+ /* For Optional API. */
+ ast_module_shutdown_ref(AST_MODULE_SELF);
+
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_ari.c b/res/res_ari.c
index 5145499be..9104eded3 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -73,6 +73,7 @@
/*** MODULEINFO
<depend type="module">res_http_websocket</depend>
+ <depend type="module">res_stasis</depend>
<support_level>core</support_level>
***/
@@ -984,9 +985,11 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
struct ast_str *buf = ast_str_create(512);
char *str = ast_json_dump_string_format(body, ast_ari_json_format());
- if (!buf) {
+ if (!buf || !str) {
ast_http_request_close_on_completion(ser);
ast_http_error(ser, 500, "Server Error", "Out of memory");
+ ast_json_free(str);
+ ast_free(buf);
goto request_failed;
}
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 60332f591..8e9aae9dd 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -1446,6 +1446,9 @@ static int load_module(void)
ast_http_uri_link(&websocketuri);
websocket_add_protocol_internal("echo", websocket_echo_callback);
+ /* For Optional API. */
+ ast_module_shutdown_ref(AST_MODULE_SELF);
+
return 0;
}
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 3e3611b36..3ac6e455f 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -24,6 +24,7 @@
*/
/*** MODULEINFO
+ <use type="module">func_periodic_hook</use>
<support_level>core</support_level>
***/
@@ -984,6 +985,9 @@ static int load_module(void)
ast_manager_register_xml("PauseMonitor", EVENT_FLAG_CALL, pause_monitor_action);
ast_manager_register_xml("UnpauseMonitor", EVENT_FLAG_CALL, unpause_monitor_action);
+ /* For Optional API. */
+ ast_module_shutdown_ref(AST_MODULE_SELF);
+
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index cee113a72..432d7587b 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -51,6 +51,7 @@
<depend>res_sorcery_config</depend>
<depend>res_sorcery_memory</depend>
<depend>res_sorcery_astdb</depend>
+ <use type="module">res_statsd</use>
<support_level>core</support_level>
***/
diff --git a/res/res_pjsip_outbound_publish.c b/res/res_pjsip_outbound_publish.c
index 0fac8adf6..f1f49d510 100644
--- a/res/res_pjsip_outbound_publish.c
+++ b/res/res_pjsip_outbound_publish.c
@@ -18,6 +18,7 @@
/*** MODULEINFO
<depend>pjproject</depend>
+ <depend>res_pjproject</depend>
<depend>res_pjsip</depend>
<support_level>core</support_level>
***/
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 4697e5cf7..7fa6e2c10 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -19,6 +19,7 @@
/*** MODULEINFO
<depend>pjproject</depend>
<depend>res_pjsip</depend>
+ <use type="module">res_statsd</use>
<support_level>core</support_level>
***/
diff --git a/res/res_pjsip_publish_asterisk.c b/res/res_pjsip_publish_asterisk.c
index fa5e4ced7..72e1e4d7e 100644
--- a/res/res_pjsip_publish_asterisk.c
+++ b/res/res_pjsip_publish_asterisk.c
@@ -20,6 +20,7 @@
<depend>pjproject</depend>
<depend>res_pjsip</depend>
<depend>res_pjsip_outbound_publish</depend>
+ <depend>res_pjsip_pubsub</depend>
<support_level>core</support_level>
***/
diff --git a/res/res_pktccops.c b/res/res_pktccops.c
index 4f6944875..e8d266cda 100644
--- a/res/res_pktccops.c
+++ b/res/res_pktccops.c
@@ -1472,6 +1472,10 @@ static int load_module(void)
}
ast_cli_register_multiple(cli_pktccops, sizeof(cli_pktccops) / sizeof(struct ast_cli_entry));
restart_pktc_thread();
+
+ /* For Optional API. */
+ ast_module_shutdown_ref(AST_MODULE_SELF);
+
return 0;
}
diff --git a/res/res_smdi.c b/res/res_smdi.c
index 4d7240104..0edabb83c 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -1405,6 +1405,10 @@ static int _unload_module(int fromload)
}
smdi_loaded = 0;
+
+ /* For Optional API. */
+ ast_module_shutdown_ref(AST_MODULE_SELF);
+
return 0;
}
diff --git a/res/res_stasis_device_state.c b/res/res_stasis_device_state.c
index 276a98b93..6527af4a6 100644
--- a/res/res_stasis_device_state.c
+++ b/res/res_stasis_device_state.c
@@ -168,22 +168,22 @@ struct ast_json *stasis_app_device_state_to_json(
struct ast_json *stasis_app_device_states_to_json(void)
{
struct ast_json *array = ast_json_array_create();
- RAII_VAR(struct ast_db_entry *, tree,
- ast_db_gettree(DEVICE_STATE_FAMILY, NULL), ast_db_freetree);
+ struct ast_db_entry *tree;
struct ast_db_entry *entry;
+ tree = ast_db_gettree(DEVICE_STATE_FAMILY, NULL);
for (entry = tree; entry; entry = entry->next) {
const char *name = strrchr(entry->key, '/');
+
if (!ast_strlen_zero(name)) {
- struct ast_str *device = ast_str_alloca(DEVICE_STATE_SIZE);
- ast_str_set(&device, 0, "%s%s",
- DEVICE_STATE_SCHEME_STASIS, ++name);
- ast_json_array_append(
- array, stasis_app_device_state_to_json(
- ast_str_buffer(device),
- ast_device_state(ast_str_buffer(device))));
+ char device[DEVICE_STATE_SIZE];
+
+ snprintf(device, sizeof(device), "%s%s", DEVICE_STATE_SCHEME_STASIS, ++name);
+ ast_json_array_append(array,
+ stasis_app_device_state_to_json(device, ast_device_state(device)));
}
}
+ ast_db_freetree(tree);
return array;
}
@@ -291,7 +291,7 @@ static void populate_cache(void)
static enum ast_device_state stasis_device_state_cb(const char *data)
{
- char buf[DEVICE_STATE_SIZE] = "";
+ char buf[DEVICE_STATE_SIZE];
ast_db_get(DEVICE_STATE_FAMILY, data, buf, sizeof(buf));
diff --git a/res/res_stasis_mailbox.c b/res/res_stasis_mailbox.c
index 4522adc10..5ed061de2 100644
--- a/res/res_stasis_mailbox.c
+++ b/res/res_stasis_mailbox.c
@@ -93,6 +93,7 @@ struct ast_json *stasis_app_mailboxes_to_json()
}
}
ao2_iterator_destroy(&iter);
+ ao2_ref(mailboxes, -1);
return array;
}
diff --git a/res/res_statsd.c b/res/res_statsd.c
index 3d7dd1684..aee0bcd5a 100644
--- a/res/res_statsd.c
+++ b/res/res_statsd.c
@@ -353,6 +353,9 @@ static int load_module(void)
return AST_MODULE_LOAD_DECLINE;
}
+ /* For Optional API. */
+ ast_module_shutdown_ref(AST_MODULE_SELF);
+
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/stasis/messaging.c b/res/stasis/messaging.c
index 8dfd99608..d398bb6d4 100644
--- a/res/stasis/messaging.c
+++ b/res/stasis/messaging.c
@@ -264,6 +264,7 @@ static struct ast_json *msg_to_json(struct ast_msg *msg)
json_vars = ast_json_array_create();
if (!json_vars) {
+ ast_msg_var_iterator_destroy(it_vars);
return NULL;
}
@@ -272,7 +273,8 @@ static struct ast_json *msg_to_json(struct ast_msg *msg)
json_tuple = ast_json_pack("{s: s}", name, value);
if (!json_tuple) {
- ast_json_free(json_vars);
+ ast_json_unref(json_vars);
+ ast_msg_var_iterator_destroy(it_vars);
return NULL;
}
diff --git a/tests/test_utils.c b/tests/test_utils.c
index d8915ba28..072cf0a39 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -27,6 +27,8 @@
/*** MODULEINFO
<depend>TEST_FRAMEWORK</depend>
+ <use type="module">res_agi</use>
+ <use type="module">res_crypto</use>
<support_level>core</support_level>
***/