kern/buffer: Handle NULL input pointer in grub_buffer_free()

The grub_buffer_free() should handle NULL input pointer, similar to
grub_free(). If the pointer is not referencing any memory location,
grub_buffer_free() need not perform any function.

Fixes: CID 396931

Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Jagannathan Raman 2022-10-17 14:04:39 +00:00 committed by Daniel Kiper
parent 306be1f813
commit 82ff9faa5b

View File

@ -49,8 +49,11 @@ grub_buffer_new (grub_size_t sz)
void
grub_buffer_free (grub_buffer_t buf)
{
grub_free (buf->data);
grub_free (buf);
if (buf != NULL)
{
grub_free (buf->data);
grub_free (buf);
}
}
grub_err_t