fs/sfs: Check if allocated memory is NULL
When using grub_zalloc(), if we are out of memory, this function can fail. After allocating memory, we should check if grub_zalloc() returns NULL. If so, we should handle this error. Fixes: CID 473856 Signed-off-by: Alec Brown <alec.r.brown@oracle.com> Reviewed-by: Ross Philipson <ross.philipson@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
1c06ec9005
commit
e3c578a56f
@ -429,6 +429,9 @@ grub_sfs_mount (grub_disk_t disk)
|
||||
- 24 /* offsetof (struct grub_sfs_objc, objects) */
|
||||
- 25); /* offsetof (struct grub_sfs_obj, filename) */
|
||||
data->label = grub_zalloc (max_len + 1);
|
||||
if (data->label == NULL)
|
||||
goto fail;
|
||||
|
||||
grub_strncpy (data->label, (char *) rootobjc->objects[0].filename, max_len);
|
||||
|
||||
grub_free (rootobjc_data);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user