diff options
author | Mark Michelson <mmichelson@digium.com> | 2015-01-30 16:47:50 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2015-01-30 16:47:50 +0000 |
commit | 43dd42d8aeee1eff844f605544901016047348e2 (patch) | |
tree | b22def97513a57f91e7d241f9a7adb497d617471 /main | |
parent | f7d23dfcc62c5491956570614365eb7ca39a7655 (diff) |
Fix some memory leaks.
These memory leaks were found and fixed by John Hardin. I'm just
committing them for him.
ASTERISK-24736 #close
Reported by Mark Michelson
Review: https://reviewboard.asterisk.org/r/4389
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@431468 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/bridge_after.c | 1 | ||||
-rw-r--r-- | main/manager.c | 6 | ||||
-rw-r--r-- | main/pbx.c | 2 | ||||
-rw-r--r-- | main/stasis_channels.c | 3 | ||||
-rw-r--r-- | main/xmldoc.c | 13 |
5 files changed, 16 insertions, 9 deletions
diff --git a/main/bridge_after.c b/main/bridge_after.c index a21cbf58e..a41f8a548 100644 --- a/main/bridge_after.c +++ b/main/bridge_after.c @@ -345,6 +345,7 @@ static void after_bridge_goto_destroy(void *data) ast_free((char *) after_bridge->parseable_goto); ast_free((char *) after_bridge->context); ast_free((char *) after_bridge->exten); + ast_free((char *) after_bridge); } /*! diff --git a/main/manager.c b/main/manager.c index 36041333f..545d9f80b 100644 --- a/main/manager.c +++ b/main/manager.c @@ -4952,8 +4952,6 @@ static void *fast_originate(void *data) S_OR(in->cid_name, NULL), in->vars, in->account, &chan, in->early_media, &assignedids); } - /* Any vars memory was passed to the ast_pbx_outgoing_xxx() calls. */ - in->vars = NULL; if (!chan) { snprintf(requested_channel, AST_CHANNEL_NAME, "%s/%s", in->tech, in->data); @@ -5400,11 +5398,11 @@ static int action_originate(struct mansession *s, const struct message *m) } } else if (!ast_strlen_zero(app)) { res = ast_pbx_outgoing_app(tech, cap, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL, assignedids.uniqueid ? &assignedids : NULL); - /* Any vars memory was passed to ast_pbx_outgoing_app(). */ + ast_variables_destroy(vars); } else { if (exten && context && pi) { res = ast_pbx_outgoing_exten(tech, cap, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL, bridge_early, assignedids.uniqueid ? &assignedids : NULL); - /* Any vars memory was passed to ast_pbx_outgoing_exten(). */ + ast_variables_destroy(vars); } else { astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'"); ast_variables_destroy(vars); diff --git a/main/pbx.c b/main/pbx.c index f13fad002..7f7f627e7 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -8827,7 +8827,7 @@ static void context_merge(struct ast_context **extcontexts, struct ast_hashtab * dupdstr = ast_strdup(prio_item->data); res1 = ast_add_extension2(new, 0, prio_item->exten, prio_item->priority, prio_item->label, - prio_item->matchcid ? prio_item->cidmatch : NULL, prio_item->app, dupdstr, prio_item->datad, prio_item->registrar); + prio_item->matchcid ? prio_item->cidmatch : NULL, prio_item->app, dupdstr, ast_free_ptr, prio_item->registrar); if (!res1 && new_exten_item && new_prio_item){ ast_verb(3,"Dropping old dialplan item %s/%s/%d [%s(%s)] (registrar=%s) due to conflict with new dialplan\n", context->name, prio_item->exten, prio_item->priority, prio_item->app, (char*)prio_item->data, prio_item->registrar); diff --git a/main/stasis_channels.c b/main/stasis_channels.c index 11a2941fa..6b3f76592 100644 --- a/main/stasis_channels.c +++ b/main/stasis_channels.c @@ -1004,13 +1004,14 @@ static struct ast_json *dtmf_end_to_json( const char *direction = ast_json_string_get(ast_json_object_get(blob, "direction")); const struct timeval *tv = stasis_message_timestamp(message); - struct ast_json *json_channel = ast_channel_snapshot_to_json(snapshot, sanitize); + struct ast_json *json_channel; /* Only present received DTMF end events as JSON */ if (strcasecmp("Received", direction) != 0) { return NULL; } + json_channel = ast_channel_snapshot_to_json(snapshot, sanitize); if (!json_channel) { return NULL; } diff --git a/main/xmldoc.c b/main/xmldoc.c index 50b6cfe7d..2a17e5287 100644 --- a/main/xmldoc.c +++ b/main/xmldoc.c @@ -2533,7 +2533,8 @@ static struct ast_xml_doc_item *xmldoc_build_list_responses(struct ast_xml_node /* Iterate over managerEvent nodes */ for (event = ast_xml_node_get_children(list_elements); event; event = ast_xml_node_get_next(event)) { struct ast_xml_node *event_instance; - const char *name = ast_xml_get_attribute(event, "name"); + RAII_VAR(const char *, name, ast_xml_get_attribute(event, "name"), + ast_xml_free_attr); struct ast_xml_doc_item *new_item; if (!name || strcmp(ast_xml_node_get_name(event), "managerEvent")) { @@ -2607,10 +2608,16 @@ static struct ast_xml_doc_item *xmldoc_build_final_response(struct ast_xml_node "managerEventInstance", NULL, NULL); if (!event_instance) { return NULL; + } else { + const char *name; + struct ast_xml_doc_item *res; + + name = ast_xml_get_attribute(final_response_event, "name"); + res = xmldoc_build_documentation_item(event_instance, name, "managerEvent"); + ast_xml_free_attr(name); + return res; } - return xmldoc_build_documentation_item(event_instance, - ast_xml_get_attribute(final_response_event, "name"), "managerEvent"); } struct ast_xml_doc_item *ast_xmldoc_build_final_response(const char *type, const char *name, const char *module) |