Skip to contentSkip to conversation

monitor: Fix Resource leak

PATCH New [email protected] 1 participant 1 message Feb 11, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 monitor: Fix Resource leak

From: Gonglei <[email protected]>

Coverity spot:
qemu_using_spice allocates memory that is stored into err, but not freed before return.

Cc Markus Armbruster <[email protected]>
---
 monitor.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
monitor.c +2 -1
index c3cc060..137d23f 100644
@@ -1095,12 +1095,13 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict,
     const char *subject  = qdict_get_try_str(qdict, "cert-subject");
     int port             = qdict_get_try_int(qdict, "port", -1);
     int tls_port         = qdict_get_try_int(qdict, "tls-port", -1);
-    Error *err;
+    Error *err = NULL;
     int ret;
 
     if (strcmp(protocol, "spice") == 0) {
         if (!qemu_using_spice(&err)) {
             qerror_report_err(err);
+            error_free(err);
             return -1;
         }
 
Signature · 1 line
1.7.12.4