mirror of
https://github.com/asterisk/asterisk.git
synced 2026-01-03 13:04:32 +00:00
Fix a memory leak in pbx_spool when using SetVar in a call file.
In pbx_spool, when we are freeing our 'outgoing' struct, we weren't deallocating the ast_variable list we had built from SetVars in a call file. Adding a call to ast_variables_destroy in our deallocation routine works, but only if the variables have not already been passed into ast_pbx_outgoing_app() or _exten(), both of which take care of destroying the variable list for us. (closes issue #16554) Reported by: mav3rick Patches: issue16554_20100119.patch uploaded by seanbright (license 71) Tested by: mav3rick git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@241543 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -122,8 +122,11 @@ static void init_outgoing(struct outgoing *o)
|
||||
ast_set_flag(&o->options, SPOOL_FLAG_ALWAYS_DELETE);
|
||||
}
|
||||
|
||||
static void free_outgoing(struct outgoing *o)
|
||||
static void free_outgoing(struct outgoing *o, int free_vars)
|
||||
{
|
||||
if (free_vars && o->vars) {
|
||||
ast_variables_destroy(o->vars);
|
||||
}
|
||||
free(o);
|
||||
}
|
||||
|
||||
@@ -367,7 +370,7 @@ static void *attempt_thread(void *data)
|
||||
ast_log(LOG_EVENT, "Queued call to %s/%s completed\n", o->tech, o->dest);
|
||||
remove_from_queue(o, "Completed");
|
||||
}
|
||||
free_outgoing(o);
|
||||
free_outgoing(o, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -380,7 +383,7 @@ static void launch_service(struct outgoing *o)
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
if ((ret = ast_pthread_create(&t,&attr,attempt_thread, o)) != 0) {
|
||||
ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret);
|
||||
free_outgoing(o);
|
||||
free_outgoing(o, 1);
|
||||
}
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
@@ -404,7 +407,7 @@ static int scan_service(char *fn, time_t now, time_t atime)
|
||||
if (o->callingpid && (o->callingpid == ast_mainpid)) {
|
||||
safe_append(o, time(NULL), "DelayedRetry");
|
||||
ast_log(LOG_DEBUG, "Delaying retry since we're currently running '%s'\n", o->fn);
|
||||
free_outgoing(o);
|
||||
free_outgoing(o, 1);
|
||||
} else {
|
||||
/* Increment retries */
|
||||
o->retries++;
|
||||
@@ -420,19 +423,19 @@ static int scan_service(char *fn, time_t now, time_t atime)
|
||||
} else {
|
||||
ast_log(LOG_EVENT, "Queued call to %s/%s expired without completion after %d attempt%s\n", o->tech, o->dest, o->retries - 1, ((o->retries - 1) != 1) ? "s" : "");
|
||||
remove_from_queue(o, "Expired");
|
||||
free_outgoing(o);
|
||||
free_outgoing(o, 1);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Invalid file contents in %s, deleting\n", fn);
|
||||
fclose(f);
|
||||
remove_from_queue(o, "Failed");
|
||||
free_outgoing(o);
|
||||
free_outgoing(o, 1);
|
||||
}
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Unable to open %s: %s, deleting\n", fn, strerror(errno));
|
||||
remove_from_queue(o, "Failed");
|
||||
free_outgoing(o);
|
||||
free_outgoing(o, 1);
|
||||
}
|
||||
} else
|
||||
ast_log(LOG_WARNING, "Out of memory :(\n");
|
||||
|
||||
Reference in New Issue
Block a user