]> xenbits.xensource.com Git - libvirt.git/commitdiff
xs_internal.c: don't use a negative value as allocation size
authorJim Meyering <meyering@redhat.com>
Tue, 2 Feb 2010 11:22:17 +0000 (12:22 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 3 Feb 2010 14:46:54 +0000 (15:46 +0100)
* src/xen/xs_internal.c (xenStoreDomainIntroduced): Don't use -1
as an allocation size upon xenStoreNumOfDomains failure.
(xenStoreDomainReleased): Likewise.

src/xen/xs_internal.c

index 1ca3da06e91fa19aa70ee177bdd62145f7bfc907..620c482a78ebf94d71b29091577479593d8d09ee 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * xs_internal.c: access to Xen Store
  *
- * Copyright (C) 2006, 2009 Red Hat, Inc.
+ * Copyright (C) 2006, 2009-2010 Red Hat, Inc.
  *
  * See COPYING.LIB for the License of this software
  *
@@ -1367,6 +1367,9 @@ int xenStoreDomainIntroduced(virConnectPtr conn,
 
 retry:
     new_domain_cnt = xenStoreNumOfDomains(conn);
+    if (new_domain_cnt < 0)
+        return -1;
+
     if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) {
         virReportOOMError(NULL);
         return -1;
@@ -1447,6 +1450,8 @@ int xenStoreDomainReleased(virConnectPtr conn,
 
 retry:
     new_domain_cnt = xenStoreNumOfDomains(conn);
+    if (new_domain_cnt < 0)
+        return -1;
 
     if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) {
         virReportOOMError(NULL);