Message ID | 20200505101908.6207-5-armbru@redhat.com |
---|---|
State | New |
Headers | show |
Series | More miscellaneous error handling fixes | expand |
On 5/5/20 12:19 PM, Markus Armbruster wrote: > migrate_get_socket_address() neglects to check > visit_type_SocketAddressList() failure. This smells like a leak, but > it actually will crash dereferencing @addrs. Pass &error_abort to > remove the code smell. > > Signed-off-by: Markus Armbruster <armbru@redhat.com> > --- > tests/qtest/migration-test.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c > index 2568c9529c..dc3490c9fa 100644 > --- a/tests/qtest/migration-test.c > +++ b/tests/qtest/migration-test.c > @@ -13,6 +13,7 @@ > #include "qemu/osdep.h" > > #include "libqtest.h" > +#include "qapi/error.h" > #include "qapi/qmp/qdict.h" > #include "qemu/module.h" > #include "qemu/option.h" > @@ -301,7 +302,6 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter) > { > QDict *rsp; > char *result; > - Error *local_err = NULL; > SocketAddressList *addrs; > Visitor *iv = NULL; > QObject *object; > @@ -310,7 +310,7 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter) > object = qdict_get(rsp, parameter); > > iv = qobject_input_visitor_new(object); > - visit_type_SocketAddressList(iv, NULL, &addrs, &local_err); > + visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort); > visit_free(iv); > > /* we are only using a single address */ > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 2568c9529c..dc3490c9fa 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "libqtest.h" +#include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qemu/module.h" #include "qemu/option.h" @@ -301,7 +302,6 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter) { QDict *rsp; char *result; - Error *local_err = NULL; SocketAddressList *addrs; Visitor *iv = NULL; QObject *object; @@ -310,7 +310,7 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter) object = qdict_get(rsp, parameter); iv = qobject_input_visitor_new(object); - visit_type_SocketAddressList(iv, NULL, &addrs, &local_err); + visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort); visit_free(iv); /* we are only using a single address */
migrate_get_socket_address() neglects to check visit_type_SocketAddressList() failure. This smells like a leak, but it actually will crash dereferencing @addrs. Pass &error_abort to remove the code smell. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- tests/qtest/migration-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)