mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-21 23:38:49 -05:00
pacsort: handle failing list_add
Since it can fail, check the return value. If it fails, we need to free the memory of the object we wanted to add to the list. Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
4b3df10d5d
commit
19d373c9b9
@ -254,7 +254,10 @@ static char *explode(struct buffer_t *buffer, struct list_t *list)
|
||||
while((end = memchr(ptr, linedelim, &buffer->mem[buffer->len] - ptr))) {
|
||||
*end = '\0';
|
||||
meta = input_new(ptr, end - ptr);
|
||||
list_add(list, meta);
|
||||
if(meta == NULL || list_add(list, meta) != 0) {
|
||||
input_free(meta);
|
||||
return NULL;
|
||||
}
|
||||
ptr = end + 1;
|
||||
}
|
||||
|
||||
@ -294,6 +297,7 @@ static int splitfile(FILE *stream, struct buffer_t *buffer, struct list_t *list)
|
||||
if(buffer->len) {
|
||||
struct input_t *meta = input_new(buffer->mem, buffer->len + 1);
|
||||
if(meta == NULL || list_add(list, meta) != 0) {
|
||||
input_free(meta);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user