mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 20:04:50 +00:00
Fix some memory leaks found while looking at how realtime
configs are handled. Also cleaned up some coding guidelines violations in app_realtime.c, mostly related to spacing git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@165255 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -389,6 +389,9 @@ static struct ast_config *realtime_directory(char *context)
|
||||
if (!cat) {
|
||||
ast_log(LOG_WARNING, "Out of memory\n");
|
||||
ast_config_destroy(cfg);
|
||||
if (rtdata) {
|
||||
ast_config_destroy(rtdata);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
ast_category_append(cfg, cat);
|
||||
|
@@ -2477,7 +2477,7 @@ bailoutandtrynormal:
|
||||
static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char *confno, int make, int dynamic,
|
||||
char *dynamic_pin, size_t pin_buf_len, int refcount, struct ast_flags *confflags)
|
||||
{
|
||||
struct ast_variable *var;
|
||||
struct ast_variable *var, *save;
|
||||
struct ast_conference *cnf;
|
||||
|
||||
/* Check first in the conference list */
|
||||
@@ -2499,6 +2499,7 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
|
||||
if (!var)
|
||||
return NULL;
|
||||
|
||||
save = var;
|
||||
while (var) {
|
||||
if (!strcasecmp(var->name, "pin")) {
|
||||
pin = ast_strdupa(var->value);
|
||||
@@ -2507,7 +2508,7 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
|
||||
}
|
||||
var = var->next;
|
||||
}
|
||||
ast_variables_destroy(var);
|
||||
ast_variables_destroy(save);
|
||||
|
||||
cnf = build_conf(confno, pin ? pin : "", pinadmin ? pinadmin : "", make, dynamic, refcount);
|
||||
}
|
||||
|
@@ -1301,11 +1301,12 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
|
||||
|
||||
static int update_realtime_member_field(struct member *mem, const char *queue_name, const char *field, const char *value)
|
||||
{
|
||||
struct ast_variable *var;
|
||||
struct ast_variable *var, *save;
|
||||
int ret = -1;
|
||||
|
||||
if (!(var = ast_load_realtime("queue_members", "interface", mem->interface, "queue_name", queue_name, NULL)))
|
||||
return ret;
|
||||
save = var;
|
||||
while (var) {
|
||||
if (!strcmp(var->name, "uniqueid"))
|
||||
break;
|
||||
@@ -1315,6 +1316,7 @@ static int update_realtime_member_field(struct member *mem, const char *queue_na
|
||||
if ((ast_update_realtime("queue_members", "uniqueid", var->value, field, value, NULL)) > -1)
|
||||
ret = 0;
|
||||
}
|
||||
ast_variables_destroy(save);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -72,22 +72,24 @@ static char *udesc = "Use the RealTime config handler system to update a value\n
|
||||
static int cli_realtime_load(int fd, int argc, char **argv)
|
||||
{
|
||||
char *header_format = "%30s %-30s\n";
|
||||
struct ast_variable *var=NULL;
|
||||
struct ast_variable *var = NULL, *save = NULL;
|
||||
|
||||
if(argc<5) {
|
||||
if (argc < 5) {
|
||||
ast_cli(fd, "You must supply a family name, a column to match on, and a value to match to.\n");
|
||||
return RESULT_FAILURE;
|
||||
}
|
||||
|
||||
var = ast_load_realtime(argv[2], argv[3], argv[4], NULL);
|
||||
|
||||
if(var) {
|
||||
if (var) {
|
||||
save = var;
|
||||
ast_cli(fd, header_format, "Column Name", "Column Value");
|
||||
ast_cli(fd, header_format, "--------------------", "--------------------");
|
||||
while(var) {
|
||||
while (var) {
|
||||
ast_cli(fd, header_format, var->name, var->value);
|
||||
var = var->next;
|
||||
}
|
||||
ast_variables_destroy(save);
|
||||
} else {
|
||||
ast_cli(fd, "No rows found matching search criteria.\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user