mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Investigate and fix memory leaks in Asterisk
Fixed memory leaks that were found in Asterisk. ASTERISK-24693 #close Reported by: Kevin Harwell Review: https://reviewboard.asterisk.org/r/4347/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@430999 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -4364,7 +4364,7 @@ static struct iax2_peer *realtime_peer(const char *peername, struct ast_sockaddr
|
|||||||
if (var && !ast_sockaddr_isnull(addr)) {
|
if (var && !ast_sockaddr_isnull(addr)) {
|
||||||
for (tmp = var; tmp; tmp = tmp->next) {
|
for (tmp = var; tmp; tmp = tmp->next) {
|
||||||
if (!strcasecmp(tmp->name, "host")) {
|
if (!strcasecmp(tmp->name, "host")) {
|
||||||
struct ast_sockaddr *hostaddr;
|
struct ast_sockaddr *hostaddr = NULL;
|
||||||
|
|
||||||
if (!ast_sockaddr_resolve(&hostaddr, tmp->value, PARSE_PORT_FORBID, AST_AF_UNSPEC)
|
if (!ast_sockaddr_resolve(&hostaddr, tmp->value, PARSE_PORT_FORBID, AST_AF_UNSPEC)
|
||||||
|| ast_sockaddr_cmp_addr(hostaddr, addr)) {
|
|| ast_sockaddr_cmp_addr(hostaddr, addr)) {
|
||||||
@@ -4372,6 +4372,7 @@ static struct iax2_peer *realtime_peer(const char *peername, struct ast_sockaddr
|
|||||||
ast_variables_destroy(var);
|
ast_variables_destroy(var);
|
||||||
var = NULL;
|
var = NULL;
|
||||||
}
|
}
|
||||||
|
ast_free(hostaddr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4486,7 +4487,7 @@ static struct iax2_user *realtime_user(const char *username, struct ast_sockaddr
|
|||||||
if (var) {
|
if (var) {
|
||||||
for (tmp = var; tmp; tmp = tmp->next) {
|
for (tmp = var; tmp; tmp = tmp->next) {
|
||||||
if (!strcasecmp(tmp->name, "host")) {
|
if (!strcasecmp(tmp->name, "host")) {
|
||||||
struct ast_sockaddr *hostaddr;
|
struct ast_sockaddr *hostaddr = NULL;
|
||||||
|
|
||||||
if (!ast_sockaddr_resolve(&hostaddr, tmp->value, PARSE_PORT_FORBID, AST_AF_UNSPEC)
|
if (!ast_sockaddr_resolve(&hostaddr, tmp->value, PARSE_PORT_FORBID, AST_AF_UNSPEC)
|
||||||
|| ast_sockaddr_cmp_addr(hostaddr, addr)) {
|
|| ast_sockaddr_cmp_addr(hostaddr, addr)) {
|
||||||
@@ -4494,6 +4495,7 @@ static struct iax2_user *realtime_user(const char *username, struct ast_sockaddr
|
|||||||
ast_variables_destroy(var);
|
ast_variables_destroy(var);
|
||||||
var = NULL;
|
var = NULL;
|
||||||
}
|
}
|
||||||
|
ast_free(hostaddr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -245,8 +245,7 @@ enum stasis_app_user_event_res {
|
|||||||
* \param event_name Name of the Userevent.
|
* \param event_name Name of the Userevent.
|
||||||
* \param source_uris URIs for the source objects to attach to event.
|
* \param source_uris URIs for the source objects to attach to event.
|
||||||
* \param sources_count Array size of source_uris.
|
* \param sources_count Array size of source_uris.
|
||||||
* \param userevent_data Custom parameters for the user event
|
* \param json_variables event blob variables.
|
||||||
* \param userevents_count Array size of userevent_data
|
|
||||||
*
|
*
|
||||||
* \return \ref stasis_app_user_event_res return code.
|
* \return \ref stasis_app_user_event_res return code.
|
||||||
*/
|
*/
|
||||||
|
@@ -610,6 +610,7 @@ static int parked_call_app_exec(struct ast_channel *chan, const char *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The parked call needs to know who is retrieving it before we move it out of the parking bridge */
|
/* The parked call needs to know who is retrieving it before we move it out of the parking bridge */
|
||||||
|
ast_assert(pu->retriever == NULL);
|
||||||
pu->retriever = ast_channel_snapshot_create(chan);
|
pu->retriever = ast_channel_snapshot_create(chan);
|
||||||
|
|
||||||
/* Create bridge */
|
/* Create bridge */
|
||||||
|
@@ -233,7 +233,7 @@ static void ast_ari_channels_originate_cb(
|
|||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.variables = ast_json_ref(body);
|
args.variables = body;
|
||||||
ast_ari_channels_originate(headers, &args, response);
|
ast_ari_channels_originate(headers, &args, response);
|
||||||
#if defined(AST_DEVMODE)
|
#if defined(AST_DEVMODE)
|
||||||
code = response->response_code;
|
code = response->response_code;
|
||||||
@@ -456,7 +456,7 @@ static void ast_ari_channels_originate_with_id_cb(
|
|||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.variables = ast_json_ref(body);
|
args.variables = body;
|
||||||
ast_ari_channels_originate_with_id(headers, &args, response);
|
ast_ari_channels_originate_with_id(headers, &args, response);
|
||||||
#if defined(AST_DEVMODE)
|
#if defined(AST_DEVMODE)
|
||||||
code = response->response_code;
|
code = response->response_code;
|
||||||
|
@@ -170,7 +170,7 @@ static void ast_ari_endpoints_send_message_cb(
|
|||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.variables = ast_json_ref(body);
|
args.variables = body;
|
||||||
ast_ari_endpoints_send_message(headers, &args, response);
|
ast_ari_endpoints_send_message(headers, &args, response);
|
||||||
#if defined(AST_DEVMODE)
|
#if defined(AST_DEVMODE)
|
||||||
code = response->response_code;
|
code = response->response_code;
|
||||||
@@ -396,7 +396,7 @@ static void ast_ari_endpoints_send_message_to_endpoint_cb(
|
|||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.variables = ast_json_ref(body);
|
args.variables = body;
|
||||||
ast_ari_endpoints_send_message_to_endpoint(headers, &args, response);
|
ast_ari_endpoints_send_message_to_endpoint(headers, &args, response);
|
||||||
#if defined(AST_DEVMODE)
|
#if defined(AST_DEVMODE)
|
||||||
code = response->response_code;
|
code = response->response_code;
|
||||||
|
@@ -281,7 +281,7 @@ static void ast_ari_events_user_event_cb(
|
|||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.variables = ast_json_ref(body);
|
args.variables = body;
|
||||||
ast_ari_events_user_event(headers, &args, response);
|
ast_ari_events_user_event(headers, &args, response);
|
||||||
#if defined(AST_DEVMODE)
|
#if defined(AST_DEVMODE)
|
||||||
code = response->response_code;
|
code = response->response_code;
|
||||||
|
@@ -111,6 +111,7 @@ static void remove_header(struct header_list *headers, const char *to_remove)
|
|||||||
AST_LIST_TRAVERSE_SAFE_BEGIN(headers, iter, next) {
|
AST_LIST_TRAVERSE_SAFE_BEGIN(headers, iter, next) {
|
||||||
if (!strcasecmp(iter->name, to_remove)) {
|
if (!strcasecmp(iter->name, to_remove)) {
|
||||||
AST_LIST_REMOVE_CURRENT(next);
|
AST_LIST_REMOVE_CURRENT(next);
|
||||||
|
destroy_header(iter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -658,7 +658,7 @@ static struct mwi_subscription *mwi_subscribe_all(
|
|||||||
static int mwi_new_subscribe(struct ast_sip_endpoint *endpoint,
|
static int mwi_new_subscribe(struct ast_sip_endpoint *endpoint,
|
||||||
const char *resource)
|
const char *resource)
|
||||||
{
|
{
|
||||||
struct ast_sip_aor *aor;
|
RAII_VAR(struct ast_sip_aor *, aor, NULL, ao2_cleanup);
|
||||||
|
|
||||||
if (ast_strlen_zero(resource)) {
|
if (ast_strlen_zero(resource)) {
|
||||||
if (ast_sip_for_each_aor(endpoint->aors, mwi_validate_for_aor, endpoint)) {
|
if (ast_sip_for_each_aor(endpoint->aors, mwi_validate_for_aor, endpoint)) {
|
||||||
|
@@ -949,7 +949,7 @@ static void resource_tree_destroy(struct resource_tree *tree)
|
|||||||
static int build_resource_tree(struct ast_sip_endpoint *endpoint, const struct ast_sip_subscription_handler *handler,
|
static int build_resource_tree(struct ast_sip_endpoint *endpoint, const struct ast_sip_subscription_handler *handler,
|
||||||
const char *resource, struct resource_tree *tree, int has_eventlist_support)
|
const char *resource, struct resource_tree *tree, int has_eventlist_support)
|
||||||
{
|
{
|
||||||
struct resource_list *list;
|
RAII_VAR(struct resource_list *, list, NULL, ao2_cleanup);
|
||||||
struct resources visited;
|
struct resources visited;
|
||||||
|
|
||||||
if (!has_eventlist_support || !(list = retrieve_resource_list(resource, handler->event_name))) {
|
if (!has_eventlist_support || !(list = retrieve_resource_list(resource, handler->event_name))) {
|
||||||
@@ -975,7 +975,6 @@ static int build_resource_tree(struct ast_sip_endpoint *endpoint, const struct a
|
|||||||
|
|
||||||
build_node_children(endpoint, handler, list, tree->root, &visited);
|
build_node_children(endpoint, handler, list, tree->root, &visited);
|
||||||
AST_VECTOR_FREE(&visited);
|
AST_VECTOR_FREE(&visited);
|
||||||
ao2_cleanup(list);
|
|
||||||
|
|
||||||
if (AST_VECTOR_SIZE(&tree->root->children) > 0) {
|
if (AST_VECTOR_SIZE(&tree->root->children) > 0) {
|
||||||
return 200;
|
return 200;
|
||||||
@@ -3183,7 +3182,6 @@ static int serialized_pubsub_on_client_refresh(void *userdata)
|
|||||||
pjsip_evsub_send_request(sub_tree->evsub, tdata);
|
pjsip_evsub_send_request(sub_tree->evsub, tdata);
|
||||||
} else {
|
} else {
|
||||||
pjsip_evsub_terminate(sub_tree->evsub, PJ_TRUE);
|
pjsip_evsub_terminate(sub_tree->evsub, PJ_TRUE);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
ao2_cleanup(sub_tree);
|
ao2_cleanup(sub_tree);
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -1817,6 +1817,8 @@ enum stasis_app_user_event_res stasis_app_user_event(const char *app_name,
|
|||||||
blob = json_variables;
|
blob = json_variables;
|
||||||
if (!blob) {
|
if (!blob) {
|
||||||
blob = ast_json_pack("{}");
|
blob = ast_json_pack("{}");
|
||||||
|
} else {
|
||||||
|
ast_json_ref(blob);
|
||||||
}
|
}
|
||||||
json_value = ast_json_string_create(event_name);
|
json_value = ast_json_string_create(event_name);
|
||||||
if (!json_value) {
|
if (!json_value) {
|
||||||
|
@@ -101,7 +101,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{#body_parameter}}
|
{{#body_parameter}}
|
||||||
args.{{c_name}} = ast_json_ref(body);
|
args.{{c_name}} = body;
|
||||||
{{/body_parameter}}
|
{{/body_parameter}}
|
||||||
{{^body_parameter}}
|
{{^body_parameter}}
|
||||||
if (ast_ari_{{c_name}}_{{c_nickname}}_parse_body(body, &args)) {
|
if (ast_ari_{{c_name}}_{{c_nickname}}_parse_body(body, &args)) {
|
||||||
|
Reference in New Issue
Block a user