On 30/10/25 02:53, [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]>
---
  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);

Or g_autofree. Anyhow,

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

          return -1;
      }


Reply via email to