On Thu, Oct 30, 2025 at 11:53 AM <[email protected]> wrote:
>
> From: Alistair Francis <[email protected]>
>
> The string needs be be freed with g_free() according to the functions
> documentation.
>
> Coverity: CID 1642762
> Fixes: f62226f7dc44 ("hw/core/loader: improve error handling in image loading
> functions")
> Signed-off-by: Alistair Francis <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
> ---
> hw/core/loader.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index 1598dca03c..e83d245202 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -153,8 +153,12 @@ ssize_t load_image_targphys_as(const char *filename,
> }
>
> if (size > max_sz) {
> + char *size_str = size_to_str(max_sz);
> +
> error_setg(errp, "%s exceeds maximum image size (%s)",
> - filename, size_to_str(max_sz));
> + filename, size_str);
> +
> + g_free(size_str);
> return -1;
> }
>
> --
> 2.51.0
>