[PATCH 10/13] vboxDumpDisplay: check return of virDomainGraphicsListenSetAddress

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

 



Error out if the allocation failed.
---
 src/vbox/vbox_common.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 43de343..1c2a432 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -3303,6 +3303,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
     PRUnichar *keyTypeUtf16   = NULL;
     PRUnichar *valueTypeUtf16 = NULL;
     char      *valueTypeUtf8  = NULL;
+    char      *netAddressUtf8 = NULL;
     IVRDxServer *VRDxServer   = NULL;
     PRBool VRDxEnabled        = PR_FALSE;
     virDomainGraphicsDefPtr graphics = NULL;
@@ -3377,7 +3378,6 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
 
     if (VRDxEnabled) {
         PRUnichar *netAddressUtf16   = NULL;
-        char      *netAddressUtf8    = NULL;
         PRBool allowMultiConnection  = PR_FALSE;
         PRBool reuseSingleConnection = PR_FALSE;
 
@@ -3391,13 +3391,14 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
         gVBoxAPI.UIVRDxServer.GetNetAddress(data, VRDxServer, &netAddressUtf16);
         if (netAddressUtf16) {
             VBOX_UTF16_TO_UTF8(netAddressUtf16, &netAddressUtf8);
-            if (STRNEQ(netAddressUtf8, ""))
-                virDomainGraphicsListenSetAddress(graphics, 0,
-                                                  netAddressUtf8, -1, true);
             VBOX_UTF16_FREE(netAddressUtf16);
-            VBOX_UTF8_FREE(netAddressUtf8);
         }
 
+        if (STRNEQ_NULLABLE(netAddressUtf8, "") &&
+            virDomainGraphicsListenSetAddress(graphics, 0,
+                                              netAddressUtf8, -1, true) < 0)
+            goto cleanup;
+
         gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection);
         if (allowMultiConnection)
             graphics->data.rdp.multiUser = true;
@@ -3418,6 +3419,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
  cleanup:
     VBOX_RELEASE(VRDxServer);
     VBOX_UTF8_FREE(valueTypeUtf8);
+    VBOX_UTF8_FREE(netAddressUtf8);
     return ret;
 }
 
-- 
2.4.10

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]