]> xenbits.xensource.com Git - libvirt.git/commitdiff
add missing error handling to virGetDomain
authorChristophe Fergeau <teuf@gnome.org>
Tue, 15 Feb 2011 03:05:38 +0000 (11:05 +0800)
committerDaniel Veillard <veillard@redhat.com>
Tue, 15 Feb 2011 03:05:38 +0000 (11:05 +0800)
When creating the virDomain::snapshots hash table, virGetDomain
wasn't checking if the creation was successful. This would then
lead to failures in the vir*DomainSnapshot functions. Better to
report this error early and make virGetDomain fail if the
snapshots hash couldn't be created.
* src/datatypes.c: report failure to make a hash table

src/datatypes.c

index e26e3320536e629ec380096c56f0e77441219ebe..d870e5d873dfbdd55bc338007bade2ca79756e76 100644 (file)
@@ -375,6 +375,12 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
         ret->id = -1;
         memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
         ret->snapshots = virHashCreate(20);
+        if (ret->snapshots == NULL) {
+            virMutexUnlock(&conn->lock);
+            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
+                            _("failed to create domain snapshots hash"));
+            goto error;
+        }
 
         if (virHashAddEntry(conn->domains, uuidstr, ret) < 0) {
             virMutexUnlock(&conn->lock);