]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix memory leak while loading priority modules and adding formats
authorMatthew Jordan <mjordan@digium.com>
Wed, 12 Jun 2013 02:25:23 +0000 (02:25 +0000)
committerMatthew Jordan <mjordan@digium.com>
Wed, 12 Jun 2013 02:25:23 +0000 (02:25 +0000)
This patch fixes two memory leaks:
 * When we load a module with the LOAD_PRIORITY flag, we remove its entry from
   the load order list. Unfortunately, we don't free the memory associated with
   entry in the list. This patch corrects that and properly frees the memory
   for the module in the list.

 * When adding a custom format (such as SILK or CELT), the routine for adding
   the format was leaking a reference. RAII_VAR cleans this up properly.

........

Merged revisions 391489 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@391507 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/format.c
main/loader.c

index cea89a2b6a23794fea3e2310b4794052bd875404..d04eb054d1114d853e560e35a2a8e50b17ffc105 100644 (file)
@@ -916,7 +916,7 @@ int init_framer(void)
 
 static int format_list_add_custom(struct ast_format_list *new)
 {
-       struct ast_format_list *entry;
+       RAII_VAR(struct ast_format_list *, entry, NULL, ao2_cleanup);
        if (!(entry = ao2_alloc(sizeof(*entry), NULL))) {
                return -1;
        }
index 7ad515f8aa14c039982a2ae4ed9512dfe81bc4a7..a0bec43eb4584c9767e0964b5c5942f6e0163416 100644 (file)
@@ -1035,6 +1035,8 @@ static int load_resource_list(struct load_order *load_order, unsigned int global
                        break;
                case AST_MODULE_LOAD_PRIORITY:
                        AST_LIST_REMOVE_CURRENT(entry);
+                       ast_free(order->resource);
+                       ast_free(order);
                        break;
                }
        }