]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
script/execute: Add a NULL check after grub_calloc() call
authorSridhar Markonda <sridharm@linux.ibm.com>
Tue, 2 Dec 2025 07:08:45 +0000 (12:38 +0530)
committerDaniel Kiper <daniel.kiper@oracle.com>
Sun, 21 Dec 2025 15:41:46 +0000 (16:41 +0100)
... in gettext_append() to handle allocation errors. This prevents NULL
pointer dereference and stops crashes during string translation.

Signed-off-by: Sridhar Markonda <sridharm@linux.ibm.com>
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/script/execute.c

index 62afcdc99167c2ab9f1b888fdbcf59b27996f7ac..369d985ee84aa26c0a7b4252ffbf5895f1892622 100644 (file)
@@ -562,6 +562,8 @@ gettext_append (struct grub_script_argv *result, const char *orig_str)
     if (*iptr == '$')
       dollar_cnt++;
   ctx.allowed_strings = grub_calloc (dollar_cnt, sizeof (ctx.allowed_strings[0]));
+  if (ctx.allowed_strings == NULL)
+    goto fail;
 
   if (parse_string (orig_str, gettext_save_allow, &ctx, 0))
     goto fail;