aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/vnc.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/ui/vnc.c b/ui/vnc.c
index eb91559b6b..651cbb8606 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3521,6 +3521,20 @@ static int vnc_display_get_address(const char *addrstr,
return ret;
}
+static void vnc_free_addresses(SocketAddress ***retsaddr,
+ size_t *retnsaddr)
+{
+ size_t i;
+
+ for (i = 0; i < *retnsaddr; i++) {
+ qapi_free_SocketAddress((*retsaddr)[i]);
+ }
+ g_free(*retsaddr);
+
+ *retsaddr = NULL;
+ *retnsaddr = 0;
+}
+
static int vnc_display_get_addresses(QemuOpts *opts,
bool reverse,
SocketAddress ***retsaddr,
@@ -3538,7 +3552,6 @@ static int vnc_display_get_addresses(QemuOpts *opts,
bool has_ipv6 = qemu_opt_get(opts, "ipv6");
bool ipv4 = qemu_opt_get_bool(opts, "ipv4", false);
bool ipv6 = qemu_opt_get_bool(opts, "ipv6", false);
- size_t i;
int displaynum = -1;
int ret = -1;
@@ -3614,16 +3627,8 @@ static int vnc_display_get_addresses(QemuOpts *opts,
ret = 0;
cleanup:
if (ret < 0) {
- for (i = 0; i < *retnsaddr; i++) {
- qapi_free_SocketAddress((*retsaddr)[i]);
- }
- g_free(*retsaddr);
- for (i = 0; i < *retnwsaddr; i++) {
- qapi_free_SocketAddress((*retwsaddr)[i]);
- }
- g_free(*retwsaddr);
- *retsaddr = *retwsaddr = NULL;
- *retnsaddr = *retnwsaddr = 0;
+ vnc_free_addresses(retsaddr, retnsaddr);
+ vnc_free_addresses(retwsaddr, retnwsaddr);
}
return ret;
}
@@ -3772,7 +3777,6 @@ void vnc_display_open(const char *id, Error **errp)
int acl = 0;
int lock_key_sync = 1;
int key_delay_ms;
- size_t i;
if (!vd) {
error_setg(errp, "VNC display not active");
@@ -3993,12 +3997,8 @@ void vnc_display_open(const char *id, Error **errp)
}
cleanup:
- for (i = 0; i < nsaddr; i++) {
- qapi_free_SocketAddress(saddr[i]);
- }
- for (i = 0; i < nwsaddr; i++) {
- qapi_free_SocketAddress(wsaddr[i]);
- }
+ vnc_free_addresses(&saddr, &nsaddr);
+ vnc_free_addresses(&wsaddr, &nwsaddr);
return;
fail: