util/setup: fix grub_util_path_list leak
Add helper grub_util_free_path_list and use it where appropriate. Found by: Coverity scan. CID: 73727
This commit is contained in:
parent
57e7f1b775
commit
0e075ac385
4 changed files with 19 additions and 8 deletions
|
@ -31,5 +31,6 @@ struct grub_util_path_list *
|
|||
grub_util_resolve_dependencies (const char *prefix,
|
||||
const char *dep_list_file,
|
||||
char *modules[]);
|
||||
void grub_util_free_path_list (struct grub_util_path_list *path_list);
|
||||
|
||||
#endif /* ! GRUB_UTIL_RESOLVE_HEADER */
|
||||
|
|
|
@ -765,6 +765,8 @@ grub_install_copy_files (const char *src,
|
|||
grub_install_compress_file (srcf, dstf, 1);
|
||||
free (dstf);
|
||||
}
|
||||
|
||||
grub_util_free_path_list (path_list);
|
||||
}
|
||||
|
||||
const char *pkglib_DATA[] = {"efiemu32.o", "efiemu64.o",
|
||||
|
|
|
@ -996,7 +996,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
|
|||
size_t prefix_size = 0;
|
||||
char *kernel_path;
|
||||
size_t offset;
|
||||
struct grub_util_path_list *path_list, *p, *next;
|
||||
struct grub_util_path_list *path_list, *p;
|
||||
size_t bss_size;
|
||||
grub_uint64_t start_address;
|
||||
void *rel_section = 0;
|
||||
|
@ -1904,11 +1904,5 @@ grub_install_generate_image (const char *dir, const char *prefix,
|
|||
free (kernel_path);
|
||||
free (rel_section);
|
||||
|
||||
while (path_list)
|
||||
{
|
||||
next = path_list->next;
|
||||
free ((void *) path_list->name);
|
||||
free (path_list);
|
||||
path_list = next;
|
||||
}
|
||||
grub_util_free_path_list (path_list);
|
||||
}
|
||||
|
|
|
@ -271,3 +271,17 @@ grub_util_resolve_dependencies (const char *prefix,
|
|||
return prev;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_util_free_path_list (struct grub_util_path_list *path_list)
|
||||
{
|
||||
struct grub_util_path_list *next;
|
||||
|
||||
while (path_list)
|
||||
{
|
||||
next = path_list->next;
|
||||
free ((void *) path_list->name);
|
||||
free (path_list);
|
||||
path_list = next;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue