From 8354d13d9bd6b826b062948216c9a285a9cb7dd3 Mon Sep 17 00:00:00 2001
From: Warner Losh <imp@FreeBSD.org>
Date: Tue, 12 Dec 2017 19:26:15 +0000
Subject: Fix resource leak. Free converted description after printing it. Also
 minor style sort of local vars.

CID: 1383606
Sponsored by: Netflix
---
 usr.sbin/efibootmgr/efibootmgr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'usr.sbin/efibootmgr')

diff --git a/usr.sbin/efibootmgr/efibootmgr.c b/usr.sbin/efibootmgr/efibootmgr.c
index 5439cba5aa26..4eb1b644e07c 100644
--- a/usr.sbin/efibootmgr/efibootmgr.c
+++ b/usr.sbin/efibootmgr/efibootmgr.c
@@ -783,9 +783,10 @@ print_boot_vars(bool verbose)
 	 * as a command epilogue
 	 */
 	struct entry *v;
-	uint32_t attrs, load_attrs;
 	uint8_t *data;
+	char *d;
 	size_t size;
+	uint32_t attrs, load_attrs;
 	int ret;
 
 	ret = efi_get_variable(EFI_GLOBAL_GUID, "BootNext", &data, &size, &attrs);
@@ -812,9 +813,9 @@ print_boot_vars(bool verbose)
 		if (ret < 0)
 			continue; /* we must have deleted it */
 		load_attrs = le32dec(data);
+		d = get_descr(data);
 		printf("%s%c %s", v->name,
-		    ((load_attrs & LOAD_OPTION_ACTIVE) ? '*': ' '),
-		    get_descr(data));
+		    ((load_attrs & LOAD_OPTION_ACTIVE) ? '*': ' '), d);
 		if (verbose)
 			print_loadopt_str(data, size);
 		else
-- 
cgit v1.2.3