public inbox for grub-devel@gnu.org
 help / color / mirror / Atom feed
* [PATCH v2] normal/menu_entry: Add grub_calloc failure check
@ 2025-12-02  7:01 Sridhar Markonda
  0 siblings, 0 replies; 3+ messages in thread
From: Sridhar Markonda @ 2025-12-02  7:01 UTC (permalink / raw)
  To: grub-devel
  Cc: daniel.kiper, phcoder, sudhakar, stefanb, nayna, sridharm, ssrish

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

Signed-off-by: Sridhar Markonda <sridharm@linux.ibm.com>
---
 grub-core/normal/menu_entry.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
index 8b0d17e3f..411b0ad53 100644
--- a/grub-core/normal/menu_entry.c
+++ b/grub-core/normal/menu_entry.c
@@ -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))
-- 
2.47.3


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-20 13:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4226.1764658927.1191.grub-devel@gnu.org>
2025-12-02 17:33 ` [PATCH v2] normal/menu_entry: Add grub_calloc failure check Avnish Chouhan
2025-12-20 13:14   ` Daniel Kiper
2025-12-02  7:01 Sridhar Markonda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox