[libvirt PATCH] fix build by NULL string handling

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

 



Fix libvirt build by taking care of NULL string handling

---
 src/openvz/openvz_driver.c | 6 +++++-
 tests/sockettest.c         | 8 ++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 1a189dbbe7..46f117cd00 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -2084,7 +2084,7 @@ openvzDomainMigratePrepare3Params(virConnectPtr dconn,
     virDomainDefPtr def = NULL;
     virDomainObjPtr vm = NULL;
     char *my_hostname = NULL;
-    const char *hostname = NULL;
+    char *hostname = NULL;
     virURIPtr uri = NULL;
     int ret = -1;
 
@@ -2149,6 +2149,10 @@ openvzDomainMigratePrepare3Params(virConnectPtr dconn,
         }
     }
 
+    if (hostname == NULL) {
+        goto error;
+    }
+
     *uri_out = g_strdup_printf("ssh://%s", hostname);
 
     ret = 0;
diff --git a/tests/sockettest.c b/tests/sockettest.c
index 29a565de40..f0a0815b88 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -188,8 +188,12 @@ static int testMaskNetwork(const char *addrstr,
         return -1;
 
     if (STRNEQ(networkstr, gotnet)) {
-        VIR_FREE(gotnet);
-        fprintf(stderr, "Expected %s, got %s\n", networkstr, gotnet);
+        if (gotnet == NULL) {
+            fprintf(stderr, "Expected %s, got empty string\n", networkstr);
+        } else {
+            fprintf(stderr, "Expected %s, got %s\n", networkstr, gotnet);
+            VIR_FREE(gotnet);
+        }
         return -1;
     }
     VIR_FREE(gotnet);
-- 
2.17.1






[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]

  Powered by Linux