res_pjsip_outbound_registration: Fix leak on vector add failure.
[asterisk/asterisk.git] / res / res_config_sqlite.c
index 6859497..0f91131 100644 (file)
@@ -874,10 +874,8 @@ static int add_cfg_entry(void *arg, int argc, char **argv, char **columnNames)
        }
 
        if (!args->cat_name || strcmp(args->cat_name, argv[RES_CONFIG_SQLITE_CONFIG_CATEGORY])) {
-               args->cat = ast_category_new(argv[RES_CONFIG_SQLITE_CONFIG_CATEGORY], "", 99999);
-
+               args->cat = ast_category_new_dynamic(argv[RES_CONFIG_SQLITE_CONFIG_CATEGORY]);
                if (!args->cat) {
-                       ast_log(LOG_WARNING, "Unable to allocate category\n");
                        return 1;
                }
 
@@ -1086,8 +1084,8 @@ static int add_rt_multi_cfg_entry(void *arg, int argc, char **argv, char **colum
                return 1;
        }
 
-       if (!(cat = ast_category_new(cat_name, "", 99999))) {
-               ast_log(LOG_WARNING, "Unable to allocate category\n");
+       cat = ast_category_new_dynamic(cat_name);
+       if (!cat) {
                return 1;
        }
 
@@ -1682,7 +1680,7 @@ static int load_module(void)
                ast_log(LOG_ERROR, "%s\n", S_OR(errormsg, sqlite_error_string(error)));
                sqlite_freemem(errormsg);
                unload_module();
-               return 1;
+               return AST_MODULE_LOAD_DECLINE;
        }
 
        sqlite_freemem(errormsg);
@@ -1702,7 +1700,7 @@ static int load_module(void)
                if (!query) {
                        ast_log(LOG_ERROR, "Unable to allocate SQL query\n");
                        unload_module();
-                       return 1;
+                       return AST_MODULE_LOAD_DECLINE;
                }
 
                ast_debug(1, "SQL query: %s\n", query);
@@ -1721,7 +1719,7 @@ static int load_module(void)
                                ast_log(LOG_ERROR, "%s\n", S_OR(errormsg, sqlite_error_string(error)));
                                sqlite_freemem(errormsg);
                                unload_module();
-                               return 1;
+                               return AST_MODULE_LOAD_DECLINE;
                        }
 
                        sqlite_freemem(errormsg);
@@ -1731,7 +1729,7 @@ static int load_module(void)
                        if (!query) {
                                ast_log(LOG_ERROR, "Unable to allocate SQL query\n");
                                unload_module();
-                               return 1;
+                               return AST_MODULE_LOAD_DECLINE;
                        }
 
                        ast_debug(1, "SQL query: %s\n", query);
@@ -1746,7 +1744,7 @@ static int load_module(void)
                                ast_log(LOG_ERROR, "%s\n", S_OR(errormsg, sqlite_error_string(error)));
                                sqlite_freemem(errormsg);
                                unload_module();
-                               return 1;
+                               return AST_MODULE_LOAD_DECLINE;
                        }
                }
                sqlite_freemem(errormsg);
@@ -1756,7 +1754,7 @@ static int load_module(void)
 
                if (error) {
                        unload_module();
-                       return 1;
+                       return AST_MODULE_LOAD_DECLINE;
                }
 
                cdr_registered = 1;
@@ -1766,12 +1764,12 @@ static int load_module(void)
 
        if (error) {
                unload_module();
-               return 1;
+               return AST_MODULE_LOAD_DECLINE;
        }
 
        cli_status_registered = 1;
 
-       return 0;
+       return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Realtime SQLite configuration",