Fix memory leak in /QUEUE -FLUSH

The queue->name must be freed.
This commit is contained in:
Kevin Easton
2017-07-11 19:01:09 +10:00
parent dbd37bc35d
commit a6a5a19e28
2 changed files with 14 additions and 13 deletions

View File

@@ -1,5 +1,7 @@
[Changes 1.2.2] [Changes 1.2.2]
* Fix memory leak in /QUEUE -FLUSH. (caf)
* Messages sent by /SV and /PASTE should be logged in the send log. (caf) * Messages sent by /SV and /PASTE should be logged in the send log. (caf)
* Change send_text() to combine command, hook and log arguments into one * Change send_text() to combine command, hook and log arguments into one

View File

@@ -267,28 +267,27 @@ static int delete_commands_from_queue (Queue *queue, int which)
/* flush a queue, deallocate the memory, and return the next in line */ /* flush a queue, deallocate the memory, and return the next in line */
static Queue *remove_a_queue (Queue *queue) static Queue *remove_a_queue (Queue *queue)
{ {
Queue *tmp; Queue *next = queue->next;
tmp = queue->next;
flush_queue(queue); flush_queue(queue);
new_free((char **)&queue); new_free(&queue->name);
return tmp; new_free(&queue);
return next;
} }
/* walk through a queue, deallocating the entries */ /* walk through a queue, deallocating the entries */
static void flush_queue (Queue *queue) static void flush_queue (Queue *queue)
{ {
CmdList *tmp, *tmp2; CmdList *cmd_list = queue->first;
tmp = queue->first;
while (tmp != NULL) while (cmd_list != NULL)
{ {
tmp2 = tmp; CmdList *next = cmd_list->next;
tmp = tmp2->next; new_free(&cmd_list->what);
if (tmp2->what != NULL) new_free(&cmd_list);
new_free(&tmp2->what); cmd_list = next;
if (tmp2)
new_free((char **)&tmp2);
} }
queue->first = NULL;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/