xnu: Fix double free in grub_xnu_devprop_add_property()
grub_xnu_devprop_add_property() should not free utf8 and utf16 as it get allocated and freed in the caller. Minor improvement: do prop fields initialization after memory allocations. Fixes: CID 292442, CID 292457, CID 292460, CID 292466 Signed-off-by: Alexey Makhalov <amakhalov@vmware.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
26a8c19307
commit
6d7a59a2a1
1 changed files with 8 additions and 9 deletions
|
@ -262,20 +262,19 @@ grub_xnu_devprop_add_property (struct grub_xnu_devprop_device_descriptor *dev,
|
||||||
if (!prop)
|
if (!prop)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
prop->name = utf8;
|
prop->data = grub_malloc (datalen);
|
||||||
prop->name16 = utf16;
|
|
||||||
prop->name16len = utf16len;
|
|
||||||
|
|
||||||
prop->length = datalen;
|
|
||||||
prop->data = grub_malloc (prop->length);
|
|
||||||
if (!prop->data)
|
if (!prop->data)
|
||||||
{
|
{
|
||||||
grub_free (prop->name);
|
|
||||||
grub_free (prop->name16);
|
|
||||||
grub_free (prop);
|
grub_free (prop);
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
grub_memcpy (prop->data, data, prop->length);
|
grub_memcpy (prop->data, data, datalen);
|
||||||
|
|
||||||
|
prop->name = utf8;
|
||||||
|
prop->name16 = utf16;
|
||||||
|
prop->name16len = utf16len;
|
||||||
|
prop->length = datalen;
|
||||||
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&dev->properties),
|
grub_list_push (GRUB_AS_LIST_P (&dev->properties),
|
||||||
GRUB_AS_LIST (prop));
|
GRUB_AS_LIST (prop));
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
|
|
Loading…
Reference in a new issue