summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-07-09 13:02:54 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2015-07-09 13:02:54 +0200
commitd8c64b7f90b053d7bdf8d83133d9a4cc5be788dd (patch)
treea5053440a57b350ad491f1c57fd94849d5d33c0c /src/boot
parenta0f7095171f03517bb44f91c67098ddd53537b54 (diff)
boot: fix memleaks in os-release parser
There is no guarantee that the os-release section contains each key only once, nor any guarantee that all keys are present. Make sure we properly free memory in both cases. Not that it matters much, as we're short-living, anyway. But correct code is always nicer to read..
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/boot.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
index eb1a4e3b66..861adff29f 100644
--- a/src/boot/efi/boot.c
+++ b/src/boot/efi/boot.c
@@ -1547,16 +1547,19 @@ static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_ima
line = content;
while ((line = line_get_key_value(content, (CHAR8 *)"=", &pos, &key, &value))) {
if (strcmpa((CHAR8 *)"PRETTY_NAME", key) == 0) {
+ FreePool(os_name);
os_name = stra_to_str(value);
continue;
}
if (strcmpa((CHAR8 *)"ID", key) == 0) {
+ FreePool(os_id);
os_id = stra_to_str(value);
continue;
}
if (strcmpa((CHAR8 *)"VERSION_ID", key) == 0) {
+ FreePool(os_version);
os_version = stra_to_str(value);
continue;
}
@@ -1571,11 +1574,11 @@ static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_ima
config_entry_add_loader(config, loaded_image->DeviceHandle, LOADER_LINUX, conf, 'l', os_name, path);
FreePool(conf);
FreePool(path);
- FreePool(os_name);
- FreePool(os_id);
- FreePool(os_version);
}
+ FreePool(os_name);
+ FreePool(os_id);
+ FreePool(os_version);
FreePool(content);
}
uefi_call_wrapper(linux_dir->Close, 1, linux_dir);