mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-29 10:39:22 +00:00
net: Check if returned pointer for allocated memory is NULL
When using grub_malloc(), the function can fail if we are out of memory. After allocating memory we should check if this function returned NULL and handle this error if it did. Signed-off-by: Alec Brown <alec.r.brown@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
dee2c14fd6
commit
1c06ec9005
1 file changed
+5
@@ -227,6 +227,11 @@ grub_net_ipv6_get_slaac (struct grub_net_card *card,
|
|||||||
}
|
}
|
||||||
|
|
||||||
slaac->name = grub_malloc (sz);
|
slaac->name = grub_malloc (sz);
|
||||||
|
if (slaac->name == NULL)
|
||||||
|
{
|
||||||
|
grub_free (slaac);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
ptr = grub_stpcpy (slaac->name, card->name);
|
ptr = grub_stpcpy (slaac->name, card->name);
|
||||||
if (grub_net_hwaddr_cmp (&card->default_address, hwaddr) != 0)
|
if (grub_net_hwaddr_cmp (&card->default_address, hwaddr) != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user