From 34f89f79eb1ae181e4f23d7a19de647d98d6a0c8 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Wed, 21 Jul 2010 08:35:31 -0600 Subject: [PATCH] savevm: Fix memory leak of compat struct Forgot to check for and free these. Found-by: Zachary Amsden Signed-off-by: Alex Williamson Signed-off-by: Aurelien Jarno --- savevm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/savevm.c b/savevm.c index 7a1de3c..4c0e5d3 100644 --- a/savevm.c +++ b/savevm.c @@ -1139,6 +1139,9 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque) QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) { QTAILQ_REMOVE(&savevm_handlers, se, entry); + if (se->compat) { + qemu_free(se->compat); + } qemu_free(se); } } @@ -1206,6 +1209,9 @@ void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd, QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { if (se->vmsd == vmsd && se->opaque == opaque) { QTAILQ_REMOVE(&savevm_handlers, se, entry); + if (se->compat) { + qemu_free(se->compat); + } qemu_free(se); } } -- 2.7.4