From 9b5950b9c6dd2322dadf2f54ecbbd24eddede278 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 10 Sep 2014 15:40:29 -0400 Subject: [PATCH 05/18] Fix some minor memory leaks. Well, one and not really another. Covscan is /almost/ a great tool. Signed-off-by: Peter Jones --- src/efibootmgr/efibootmgr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c index 1c65c07..88a4ef7 100644 --- a/src/efibootmgr/efibootmgr.c +++ b/src/efibootmgr/efibootmgr.c @@ -627,8 +627,11 @@ construct_boot_order(char *bootorder, int keep, size_t data_size = 0; rc = parse_boot_order(bootorder, (uint16_t **)&data, &data_size); - if (rc < 0 || data_size == 0) + if (rc < 0 || data_size == 0) { + if (data) /* this can't actually happen, but covscan believes */ + free(data); return rc; + } if (!keep) { *ret_data = data; @@ -651,8 +654,11 @@ construct_boot_order(char *bootorder, int keep, size_t new_data_size = data_size + bo.data_size; uint16_t *new_data = calloc(1, new_data_size); - if (!new_data) + if (!new_data) { + if (data) + free(data); return -1; + } memcpy(new_data, data, data_size); memcpy(new_data + (data_size / sizeof (*new_data)), bo.data, -- 1.9.3