Index: pbx/pbx_spool.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx/pbx_spool.c,v retrieving revision 1.28 diff -u -r1.28 pbx_spool.c --- pbx/pbx_spool.c 14 Sep 2005 20:46:50 -0000 1.28 +++ pbx/pbx_spool.c 11 Oct 2005 20:01:52 -0000 @@ -91,7 +91,6 @@ /* Maximum length of call */ int maxlen; - }; static void init_outgoing(struct outgoing *o) @@ -102,6 +101,21 @@ o->waittime = 45; } +static void free_outgoing(struct outgoing *o) +{ + struct ast_variable *i, *last = NULL; + for (i = o->vars; i; i = i->next) { + if (last) { + free(last); + } + last = i; + } + if (last) { + free(last); + } + free(o); +} + static int apply_outgoing(struct outgoing *o, char *fn, FILE *f) { char buf[256]; @@ -265,7 +279,7 @@ ast_log(LOG_EVENT, "Queued call to %s/%s completed\n", o->tech, o->dest); unlink(o->fn); } - free(o); + free_outgoing(o); return NULL; } @@ -277,7 +291,7 @@ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (ast_pthread_create(&t,&attr,attempt_thread, o) == -1) { ast_log(LOG_WARNING, "Unable to create thread :(\n"); - free(o); + free_outgoing(o); } } @@ -314,18 +328,18 @@ return now; } 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" : ""); - free(o); + free_outgoing(o); unlink(fn); return 0; } } else { - free(o); + free_outgoing(o); ast_log(LOG_WARNING, "Invalid file contents in %s, deleting\n", fn); fclose(f); unlink(fn); } } else { - free(o); + free_outgoing(o); ast_log(LOG_WARNING, "Unable to open %s: %s, deleting\n", fn, strerror(errno)); unlink(fn); }