loader/xnu: Check if pointer is NULL before using it

Fixes: CID 73654

Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Paulo Flabiano Smorigo 2020-11-30 10:36:00 -03:00 committed by Daniel Kiper
parent 4b4027b6b1
commit 7c8a2b5d14

View File

@ -670,6 +670,9 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
char *name, *nameend;
int namelen;
if (infoplistname == NULL)
return grub_error (GRUB_ERR_BAD_FILENAME, N_("missing p-list filename"));
name = get_name_ptr (infoplistname);
nameend = grub_strchr (name, '/');
@ -701,10 +704,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
else
macho = 0;
if (infoplistname)
infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
else
infoplist = 0;
infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
grub_errno = GRUB_ERR_NONE;
if (infoplist)
{