]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
migration: fix vmdesc leak on vmstate_save() error
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 12 Sep 2019 12:25:09 +0000 (16:25 +0400)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Wed, 25 Sep 2019 14:51:19 +0000 (15:51 +0100)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20190912122514.22504-2-marcandre.lureau@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
migration/qjson.h
migration/savevm.c

index 41664f2d71b545bbac60de5edb99126303c05f66..1786bb5864a0973df95626668d3140d268c92164 100644 (file)
@@ -24,4 +24,6 @@ void json_start_object(QJSON *json, const char *name);
 const char *qjson_get_str(QJSON *json);
 void qjson_finish(QJSON *json);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QJSON, qjson_destroy)
+
 #endif /* QEMU_QJSON_H */
index ee06f91d421965317741fdb83d552c8977ae79dd..bb9462a54d6d605e2f7f0cc294484ea0da4133e0 100644 (file)
@@ -1314,7 +1314,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
                                                     bool in_postcopy,
                                                     bool inactivate_disks)
 {
-    QJSON *vmdesc;
+    g_autoptr(QJSON) vmdesc = NULL;
     int vmdesc_len;
     SaveStateEntry *se;
     int ret;
@@ -1375,7 +1375,6 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
         qemu_put_be32(f, vmdesc_len);
         qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len);
     }
-    qjson_destroy(vmdesc);
 
     return 0;
 }