From: Alistair Francis Date: Thu, 30 Oct 2025 01:53:06 +0000 (+1000) Subject: hw/core/loader: Free the allocated string from size_to_str() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de0a5b1fbd1f842719af9311ba2a3bcd0d2bc482;p=thirdparty%2Fqemu.git hw/core/loader: Free the allocated string from size_to_str() 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 Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20251030015306.2279148-3-alistair.francis@wdc.com> Signed-off-by: Alistair Francis --- 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; }