diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-03-22 12:51:05 +0100 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2012-03-27 09:13:48 -0300 |
commit | 8b714d3747e6870db85dd9382adb8ee371633092 (patch) | |
tree | 5cf89bbeb3516c49b8ae87931aac73e40ce7e5cb /qapi/qmp-input-visitor.c | |
parent | 2c7ff93359e820f90bfb4ac9efd6ec35949e5630 (diff) | |
download | qemu-8b714d3747e6870db85dd9382adb8ee371633092.zip qemu-8b714d3747e6870db85dd9382adb8ee371633092.tar.gz qemu-8b714d3747e6870db85dd9382adb8ee371633092.tar.bz2 |
qapi: fix memory leak on error
QmpInputVisitor would leak the malloced struct if the stack was
overflowed. This can be easily fixed using error_propagate.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'qapi/qmp-input-visitor.c')
-rw-r--r-- | qapi/qmp-input-visitor.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index b4013cc..ef9288f 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -86,6 +86,7 @@ static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind, { QmpInputVisitor *qiv = to_qiv(v); const QObject *qobj = qmp_input_get_object(qiv, name); + Error *err = NULL; if (!qobj || qobject_type(qobj) != QTYPE_QDICT) { error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", @@ -93,8 +94,9 @@ static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind, return; } - qmp_input_push(qiv, qobj, errp); - if (error_is_set(errp)) { + qmp_input_push(qiv, qobj, &err); + if (err) { + error_propagate(errp, err); return; } |