mirror of
https://github.com/linux-speakup/espeakup.git
synced 2026-08-24 08:34:18 +02:00
Fix a memory leak.
If we fail to add entries to the queue in queue_add_cmd or queue_add_text, properly free the entry.
This commit is contained in:
parent
ccb8cea91e
commit
40479540b4
3 changed files with 18 additions and 6 deletions
5
queue.c
5
queue.c
|
|
@ -45,7 +45,7 @@ struct queue_t *new_queue(void)
|
|||
return q;
|
||||
}
|
||||
|
||||
void queue_add(struct queue_t *q, void *data)
|
||||
int queue_add(struct queue_t *q, void *data)
|
||||
{
|
||||
struct queue_entry_t *tmp;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ void queue_add(struct queue_t *q, void *data)
|
|||
tmp = malloc(sizeof(struct queue_entry_t));
|
||||
if (!tmp) {
|
||||
printf("Unable to allocate memory for queue entry.\n");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
tmp->data = data;
|
||||
tmp->next = NULL;
|
||||
|
|
@ -65,6 +65,7 @@ void queue_add(struct queue_t *q, void *data)
|
|||
}
|
||||
if (!q->head)
|
||||
q->head = tmp;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void queue_remove(struct queue_t *q)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue