From: Peter Jones Date: Wed, 10 Sep 2014 19:40:29 +0000 (-0400) Subject: Fix some minor memory leaks. X-Git-Tag: android-x86-7.1-r1~118 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9b5950b9c6dd2322dadf2f54ecbbd24eddede278;p=android-x86%2Fexternal-efibootmgr.git Fix some minor memory leaks. Well, one and not really another. Covscan is /almost/ a great tool. Signed-off-by: Peter Jones --- 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,