From: Alistair Francis <alistair.francis@wdc.com>
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 <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251030015306.2279148-3-alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
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 3d2c1ae286..2fad7292e5 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.52.0