qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC][PATCH v2 06/17] qapi: fix memory leak for async marsh


From: Michael Roth
Subject: [Qemu-devel] [RFC][PATCH v2 06/17] qapi: fix memory leak for async marshalling code
Date: Mon, 18 Apr 2011 10:02:22 -0500

When generating the callback function for an async command, if we expect
a QString we copy it into a native char* type, then call the completion
function. We should free it after calling the completion function, since
the completion function will later copy it into a new QString before
adding it to the response object and then passing it on to the wire.

Signed-off-by: Michael Roth <address@hidden>
---
 qmp-gen.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/qmp-gen.py b/qmp-gen.py
index 4164692..3667ec5 100644
--- a/qmp-gen.py
+++ b/qmp-gen.py
@@ -349,6 +349,10 @@ static void qmp_%(c_name)s_cb(void *qmp__opaque, QObject 
*qmp__retval, Error *qm
         ret += cgen('    qmp__cb->cb(qmp__cb->opaque, qmp__err);')
     else:
         ret += cgen('    qmp__cb->cb(qmp__cb->opaque, qmp__native_retval, 
qmp__err);')
+    if retval != 'none' and qmp_type_should_free(retval):
+        ret += cgen('    %(free)s(qmp__native_retval);',
+                    free=qapi_free_func(retval))
+
     ret += cgen('}')
 
     return ret
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]