script/execute: Add a NULL check after grub_calloc() call

... 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>
This commit is contained in:
Sridhar Markonda 2025-12-02 12:38:45 +05:30 committed by Daniel Kiper
parent 02cae1a357
commit c0669af6a8

View File

@ -562,6 +562,8 @@ gettext_append (struct grub_script_argv *result, const char *orig_str)
if (*iptr == '$') if (*iptr == '$')
dollar_cnt++; dollar_cnt++;
ctx.allowed_strings = grub_calloc (dollar_cnt, sizeof (ctx.allowed_strings[0])); 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)) if (parse_string (orig_str, gettext_save_allow, &ctx, 0))
goto fail; goto fail;