Author: kharwell
Date: Fri Jan 23 09:24:20 2015
New Revision: 431016

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=431016
Log:
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/
........

Merged revisions 430999 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    certified/branches/13.1/   (props changed)
    certified/branches/13.1/channels/chan_iax2.c
    certified/branches/13.1/include/asterisk/stasis_app.h
    certified/branches/13.1/res/parking/parking_applications.c
    certified/branches/13.1/res/res_ari_channels.c
    certified/branches/13.1/res/res_ari_endpoints.c
    certified/branches/13.1/res/res_ari_events.c
    certified/branches/13.1/res/res_pjsip/pjsip_global_headers.c
    certified/branches/13.1/res/res_pjsip_mwi.c
    certified/branches/13.1/res/res_pjsip_pubsub.c
    certified/branches/13.1/res/res_stasis.c
    certified/branches/13.1/rest-api-templates/param_parsing.mustache

Propchange: certified/branches/13.1/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: certified/branches/13.1/channels/chan_iax2.c
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/channels/chan_iax2.c?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/channels/chan_iax2.c (original)
+++ certified/branches/13.1/channels/chan_iax2.c Fri Jan 23 09:24:20 2015
@@ -4406,7 +4406,7 @@
                if (var && !ast_sockaddr_isnull(addr)) {
                        for (tmp = var; tmp; tmp = tmp->next) {
                                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)
                                                || 
ast_sockaddr_cmp_addr(hostaddr, addr)) {
@@ -4414,6 +4414,7 @@
                                                ast_variables_destroy(var);
                                                var = NULL;
                                        }
+                                       ast_free(hostaddr);
                                        break;
                                }
                        }
@@ -4528,7 +4529,7 @@
                if (var) {
                        for (tmp = var; tmp; tmp = tmp->next) {
                                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)
                                                || 
ast_sockaddr_cmp_addr(hostaddr, addr)) {
@@ -4536,6 +4537,7 @@
                                                ast_variables_destroy(var);
                                                var = NULL;
                                        }
+                                       ast_free(hostaddr);
                                        break;
                                }
                        }

Modified: certified/branches/13.1/include/asterisk/stasis_app.h
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/include/asterisk/stasis_app.h?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/include/asterisk/stasis_app.h (original)
+++ certified/branches/13.1/include/asterisk/stasis_app.h Fri Jan 23 09:24:20 
2015
@@ -245,8 +245,7 @@
  * \param event_name Name of the Userevent.
  * \param source_uris URIs for the source objects to attach to event.
  * \param sources_count Array size of source_uris.
- * \param userevent_data Custom parameters for the user event
- * \param userevents_count Array size of userevent_data
+ * \param json_variables event blob variables.
  *
  * \return \ref stasis_app_user_event_res return code.
  */

Modified: certified/branches/13.1/res/parking/parking_applications.c
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/parking/parking_applications.c?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/res/parking/parking_applications.c (original)
+++ certified/branches/13.1/res/parking/parking_applications.c Fri Jan 23 
09:24:20 2015
@@ -610,6 +610,7 @@
        }
 
        /* 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);
 
        /* Create bridge */

Modified: certified/branches/13.1/res/res_ari_channels.c
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_ari_channels.c?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/res/res_ari_channels.c (original)
+++ certified/branches/13.1/res/res_ari_channels.c Fri Jan 23 09:24:20 2015
@@ -226,7 +226,7 @@
                        goto fin;
                }
        }
-       args.variables = ast_json_ref(body);
+       args.variables = body;
        ast_ari_channels_originate(headers, &args, response);
 #if defined(AST_DEVMODE)
        code = response->response_code;
@@ -442,7 +442,7 @@
                        goto fin;
                }
        }
-       args.variables = ast_json_ref(body);
+       args.variables = body;
        ast_ari_channels_originate_with_id(headers, &args, response);
 #if defined(AST_DEVMODE)
        code = response->response_code;

Modified: certified/branches/13.1/res/res_ari_endpoints.c
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_ari_endpoints.c?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/res/res_ari_endpoints.c (original)
+++ certified/branches/13.1/res/res_ari_endpoints.c Fri Jan 23 09:24:20 2015
@@ -170,7 +170,7 @@
                        goto fin;
                }
        }
-       args.variables = ast_json_ref(body);
+       args.variables = body;
        ast_ari_endpoints_send_message(headers, &args, response);
 #if defined(AST_DEVMODE)
        code = response->response_code;
@@ -396,7 +396,7 @@
                        goto fin;
                }
        }
-       args.variables = ast_json_ref(body);
+       args.variables = body;
        ast_ari_endpoints_send_message_to_endpoint(headers, &args, response);
 #if defined(AST_DEVMODE)
        code = response->response_code;

Modified: certified/branches/13.1/res/res_ari_events.c
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_ari_events.c?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/res/res_ari_events.c (original)
+++ certified/branches/13.1/res/res_ari_events.c Fri Jan 23 09:24:20 2015
@@ -281,7 +281,7 @@
                        goto fin;
                }
        }
-       args.variables = ast_json_ref(body);
+       args.variables = body;
        ast_ari_events_user_event(headers, &args, response);
 #if defined(AST_DEVMODE)
        code = response->response_code;

Modified: certified/branches/13.1/res/res_pjsip/pjsip_global_headers.c
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip/pjsip_global_headers.c?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/res/res_pjsip/pjsip_global_headers.c (original)
+++ certified/branches/13.1/res/res_pjsip/pjsip_global_headers.c Fri Jan 23 
09:24:20 2015
@@ -111,6 +111,7 @@
        AST_LIST_TRAVERSE_SAFE_BEGIN(headers, iter, next) {
                if (!strcasecmp(iter->name, to_remove)) {
                        AST_LIST_REMOVE_CURRENT(next);
+                       destroy_header(iter);
                        break;
                }
        }

Modified: certified/branches/13.1/res/res_pjsip_mwi.c
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip_mwi.c?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/res/res_pjsip_mwi.c (original)
+++ certified/branches/13.1/res/res_pjsip_mwi.c Fri Jan 23 09:24:20 2015
@@ -658,7 +658,7 @@
 static int mwi_new_subscribe(struct ast_sip_endpoint *endpoint,
                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_sip_for_each_aor(endpoint->aors, mwi_validate_for_aor, 
endpoint)) {

Modified: certified/branches/13.1/res/res_pjsip_pubsub.c
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip_pubsub.c?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/res/res_pjsip_pubsub.c (original)
+++ certified/branches/13.1/res/res_pjsip_pubsub.c Fri Jan 23 09:24:20 2015
@@ -949,7 +949,7 @@
 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)
 {
-       struct resource_list *list;
+       RAII_VAR(struct resource_list *, list, NULL, ao2_cleanup);
        struct resources visited;
 
        if (!has_eventlist_support || !(list = retrieve_resource_list(resource, 
handler->event_name))) {
@@ -975,7 +975,6 @@
 
        build_node_children(endpoint, handler, list, tree->root, &visited);
        AST_VECTOR_FREE(&visited);
-       ao2_cleanup(list);
 
        if (AST_VECTOR_SIZE(&tree->root->children) > 0) {
                return 200;
@@ -3177,7 +3176,6 @@
                pjsip_evsub_send_request(sub_tree->evsub, tdata);
        } else {
                pjsip_evsub_terminate(sub_tree->evsub, PJ_TRUE);
-               return 0;
        }
        ao2_cleanup(sub_tree);
        return 0;

Modified: certified/branches/13.1/res/res_stasis.c
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_stasis.c?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/res/res_stasis.c (original)
+++ certified/branches/13.1/res/res_stasis.c Fri Jan 23 09:24:20 2015
@@ -1804,6 +1804,8 @@
        blob = json_variables;
        if (!blob) {
                blob = ast_json_pack("{}");
+       } else {
+               ast_json_ref(blob);
        }
        json_value = ast_json_string_create(event_name);
        if (!json_value) {

Modified: certified/branches/13.1/rest-api-templates/param_parsing.mustache
URL: 
http://svnview.digium.com/svn/asterisk/certified/branches/13.1/rest-api-templates/param_parsing.mustache?view=diff&rev=431016&r1=431015&r2=431016
==============================================================================
--- certified/branches/13.1/rest-api-templates/param_parsing.mustache (original)
+++ certified/branches/13.1/rest-api-templates/param_parsing.mustache Fri Jan 
23 09:24:20 2015
@@ -101,7 +101,7 @@
                }
        }
 {{#body_parameter}}
-       args.{{c_name}} = ast_json_ref(body);
+       args.{{c_name}} = body;
 {{/body_parameter}}
 {{^body_parameter}}
        if (ast_ari_{{c_name}}_{{c_nickname}}_parse_body(body, &args)) {


-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

Reply via email to