From: Avnish Chouhan Date: Tue, 28 Oct 2025 16:31:59 +0000 (+0530) Subject: normal/completion: Add missing grub_malloc() failure check X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c0d2f76d55fcbf433b3525a3f3c4aa7d697b1105;p=thirdparty%2Fgrub.git normal/completion: Add missing grub_malloc() failure check This patch adds a NULL check after grub_malloc() call. Missing a failure check after calling grub_malloc() can lead to undefined behavior. If the allocation fails and returns NULL subsequent dereferencing or writing to the pointer will likely result in a runtime error such as a segmentation fault. Signed-off-by: Avnish Chouhan Reviewed-by: Sudhakar Kuppusamy Reviewed-by: Daniel Kiper --- diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c index 18cadfa85..4058e0a62 100644 --- a/grub-core/normal/completion.c +++ b/grub-core/normal/completion.c @@ -490,6 +490,9 @@ grub_normal_do_completion (char *buf, int *restore, spaces++; ret = grub_malloc (match_len - current_len + grub_strlen (suffix) + spaces + 1); + if (ret == NULL) + goto fail; + newstr = ret; for (escstr = match + current_len; *escstr; escstr++) {