diff options
author | Adrian Vovk <adrianvovk@gmail.com> | 2024-10-01 22:53:02 +0200 |
---|---|---|
committer | Adrian Vovk <adrianvovk@gmail.com> | 2024-11-26 22:33:10 +0100 |
commit | e2501a851e10f5279862b2bccbdd9184572cce6a (patch) | |
tree | 2bac3d4b9ed3609e7fd4e4c0b0efbc864f48e229 /src | |
parent | sd-stub: Fixup typo & measurement order (diff) | |
download | systemd-e2501a851e10f5279862b2bccbdd9184572cce6a.tar.xz systemd-e2501a851e10f5279862b2bccbdd9184572cce6a.zip |
bootspec: Fixup memory leak
This would previously leak memory: the array was deleted but contents
inside of the array were not
Diffstat (limited to '')
-rw-r--r-- | src/shared/bootspec.c | 7 | ||||
-rw-r--r-- | src/shared/bootspec.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 584515a297..49440dded1 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -44,6 +44,8 @@ static const char* const boot_entry_type_json_table[_BOOT_ENTRY_TYPE_MAX] = { DEFINE_STRING_TABLE_LOOKUP_TO_STRING(boot_entry_type_json, BootEntryType); +static void boot_entry_addons_done(BootEntryAddons *addons); + static void boot_entry_free(BootEntry *entry) { assert(entry); @@ -59,7 +61,7 @@ static void boot_entry_free(BootEntry *entry) { free(entry->machine_id); free(entry->architecture); strv_free(entry->options); - free(entry->local_addons.items); + boot_entry_addons_done(&entry->local_addons); free(entry->kernel); free(entry->efi); strv_free(entry->initrd); @@ -426,7 +428,8 @@ void boot_config_free(BootConfig *config) { FOREACH_ARRAY(i, config->entries, config->n_entries) boot_entry_free(i); free(config->entries); - free(config->global_addons.items); + + boot_entry_addons_done(&config->global_addons); set_free(config->inodes_seen); } diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h index 58c676fbec..0bb75669ce 100644 --- a/src/shared/bootspec.h +++ b/src/shared/bootspec.h @@ -31,8 +31,6 @@ typedef struct BootEntryAddons { size_t n_items; } BootEntryAddons; -BootEntryAddon* boot_entry_addon_free(BootEntryAddon *t); - typedef struct BootEntry { BootEntryType type; bool reported_by_loader; |