diff options
author | Wenchao Xia <xiawenc@linux.vnet.ibm.com> | 2013-11-06 02:35:50 +0800 |
---|---|---|
committer | Anthony Liguori <aliguori@amazon.com> | 2013-11-05 19:58:38 -0800 |
commit | 3dce9cad5a6c0b0dbe0830973b270c9466c8ab4b (patch) | |
tree | 09562c139c5b9d2ce5ba3d4e6e7ba0ebaa655485 /qapi | |
parent | 7d579514a5a7b308b52d4e8567aa9bd1f7aa761b (diff) | |
download | qemu-3dce9cad5a6c0b0dbe0830973b270c9466c8ab4b.zip qemu-3dce9cad5a6c0b0dbe0830973b270c9466c8ab4b.tar.gz qemu-3dce9cad5a6c0b0dbe0830973b270c9466c8ab4b.tar.bz2 |
qapi: fix memleak by adding implict struct functions in dealloc visitor
Otherwise member "base" is leaked in a qapi_free_STRUCTURE() call.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1383676551-18806-2-git-send-email-xiawenc@linux.vnet.ibm.com
Cc: qemu-stable@nongnu.org
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
Diffstat (limited to 'qapi')
-rw-r--r-- | qapi/qapi-dealloc-visitor.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index 1334de3..dc53545 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -76,6 +76,24 @@ static void qapi_dealloc_end_struct(Visitor *v, Error **errp) } } +static void qapi_dealloc_start_implicit_struct(Visitor *v, + void **obj, + size_t size, + Error **errp) +{ + QapiDeallocVisitor *qov = to_qov(v); + qapi_dealloc_push(qov, obj); +} + +static void qapi_dealloc_end_implicit_struct(Visitor *v, Error **errp) +{ + QapiDeallocVisitor *qov = to_qov(v); + void **obj = qapi_dealloc_pop(qov); + if (obj) { + g_free(*obj); + } +} + static void qapi_dealloc_start_list(Visitor *v, const char *name, Error **errp) { QapiDeallocVisitor *qov = to_qov(v); @@ -162,6 +180,8 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void) v->visitor.start_struct = qapi_dealloc_start_struct; v->visitor.end_struct = qapi_dealloc_end_struct; + v->visitor.start_implicit_struct = qapi_dealloc_start_implicit_struct; + v->visitor.end_implicit_struct = qapi_dealloc_end_implicit_struct; v->visitor.start_list = qapi_dealloc_start_list; v->visitor.next_list = qapi_dealloc_next_list; v->visitor.end_list = qapi_dealloc_end_list; |