[Buildroot] [PATCH 2/2] Check if bootcurrent is valid before using it

Rhidian De Wit <[email protected]>
Newsgroups net.busybox.buildroot
Message-ID <[email protected]>
Signed-off-by: Rhidian De Wit <[email protected]>
---
 src/bootloaders/efi.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/bootloaders/efi.c b/src/bootloaders/efi.c
index 631ea39d..15cbf417 100644
--- a/src/bootloaders/efi.c
+++ b/src/bootloaders/efi.c
@@ -510,12 +510,15 @@ gchar *r_efi_get_current_bootname(RaucConfig *config, GError **error)
 		return NULL;
 	}
 
-	g_hash_table_iter_init(&iter, config->slots);
-	while (g_hash_table_iter_next(&iter, NULL, (gpointer*) &slot)) {
-		if (g_strcmp0(slot->bootname, bootcurrent->name) == 0) {
-			return g_strdup(slot->bootname);
-		}
-	}
+  if (bootcurrent != NULL)
+  {
+    g_hash_table_iter_init(&iter, config->slots);
+    while (g_hash_table_iter_next(&iter, NULL, (gpointer*) &slot)) {
+      if (g_strcmp0(slot->bootname, bootcurrent->name) == 0) {
+        return g_strdup(slot->bootname);
+      }
+    }
+  }
 
 	g_set_error(error,
 			R_BOOTCHOOSER_ERROR,
-- 
2.51.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.