From: Sridhar Markonda Date: Tue, 2 Dec 2025 07:08:45 +0000 (+0530) Subject: script/execute: Add a NULL check after grub_calloc() call X-Git-Tag: grub-2.14~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0669af6a86b57283087cdea2244332eb892f21c;p=thirdparty%2Fgrub.git 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 Signed-off-by: Sudhakar Kuppusamy Reviewed-by: Daniel Kiper --- diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index 62afcdc99..369d985ee 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -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;