Skip to contentSkip to conversation

normal/menu_entry: Add grub_calloc failure check

PATCH New Sridhar Markonda 1 participant 1 message Dec 2, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 normal/menu_entry: Add grub_calloc failure check

Add a NULL check to prevent failure from grub_calloc in update_screen. This stops possible NULL pointer dereference and avoids unexpected behavior.

---
 grub-core/normal/menu_entry.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
grub-core/normal/menu_entry.c +6 -2
index 8b0d17e3f..411b0ad53 100644
@@ -295,8 +295,12 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
 
 	  pos = linep->pos + (term_screen - screen->terms);
 
-	  if (!*pos)
-	    *pos = grub_calloc (linep->len + 1, sizeof (**pos));
+	  if (*pos == NULL)
+	    {
+	      *pos = grub_calloc (linep->len + 1, sizeof (**pos));
+	      if (*pos == NULL)
+		return;
+	    }
 
 	  if (i == region_start || linep == screen->lines + screen->line
 	      || (i > region_start && mode == ALL_LINES))
Signature · 7 lines
2.47.3


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel