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>
This commit is contained in:
parent
2c7ff93359
commit
8b714d3747
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user