]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvir.c: avoid NULL dereference in virStoragePoolSetAutostart
authorJim Meyering <meyering@redhat.com>
Wed, 2 Sep 2009 15:47:51 +0000 (17:47 +0200)
committerJim Meyering <meyering@redhat.com>
Thu, 3 Sep 2009 16:04:23 +0000 (18:04 +0200)
* src/libvirt.c (virStoragePoolSetAutostart): Return -1 if the pool
argument is invalid, rather than "goto error" where we could dereference
that possibly-NULL "pool".
(virConnectFindStoragePoolSources): Likewise.
(virConnectNumOfDomains): Likewise.
Daniel P. Berrange spotted that the two latter functions
needed the same treatment.

src/libvirt.c

index 397792820fb0adf53ea7cacdb5f211d307b92dbb..6f204caeb64c828c44d5b4d15420db9e7c57262b 100644 (file)
@@ -1606,7 +1606,7 @@ virConnectNumOfDomains(virConnectPtr conn)
 
     if (!VIR_IS_CONNECT(conn)) {
         virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
-        goto error;
+        return -1;
     }
 
     if (conn->driver->numOfDomains) {
@@ -6451,7 +6451,7 @@ virConnectFindStoragePoolSources(virConnectPtr conn,
 
     if (!VIR_IS_CONNECT(conn)) {
         virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
-        goto error;
+        return NULL;
     }
     if (type == NULL) {
         virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
@@ -7339,7 +7339,7 @@ virStoragePoolSetAutostart(virStoragePoolPtr pool,
 
     if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
         virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
-        goto error;
+        return -1;
     }
 
     if (pool->conn->flags & VIR_CONNECT_RO) {