Browse Source

hw/loader: Use g_autofree in unpack_efi_zboot_image()

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Daan De Meyer <daan.j.demeyer@gmail.com>
Message-ID: <20251124123521.1058183-4-daan.j.demeyer@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
pull/316/head
Daan De Meyer 9 months ago
committed by Philippe Mathieu-Daudé
parent
commit
3fd0734cb3
  1. 5
      hw/core/loader.c

5
hw/core/loader.c

@ -898,7 +898,7 @@ ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size)
{
const size_t max_bytes = LOAD_IMAGE_MAX_DECOMPRESSED_BYTES;
const struct linux_efi_zboot_header *header;
uint8_t *data = NULL;
g_autofree uint8_t *data = NULL;
ssize_t ploff, plsize;
ssize_t bytes;
@ -936,12 +936,11 @@ ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size)
bytes = gunzip(data, max_bytes, *buffer + ploff, plsize);
if (bytes < 0) {
fprintf(stderr, "failed to decompress EFI zboot image\n");
g_free(data);
return -1;
}
g_free(*buffer);
*buffer = g_realloc(data, bytes);
*buffer = g_realloc(g_steal_pointer(&data), bytes);
*size = bytes;
return bytes;
}

Loading…
Cancel
Save