]> xenbits.xensource.com Git - libvirt.git/commitdiff
* src/xml.c: markmc pointed out that using number(xpath) could lead
authorDaniel Veillard <veillard@redhat.com>
Thu, 10 Aug 2006 14:26:35 +0000 (14:26 +0000)
committerDaniel Veillard <veillard@redhat.com>
Thu, 10 Aug 2006 14:26:35 +0000 (14:26 +0000)
  to NaN and following comparison would be wrong in a couple of places
  if the element looked at was missing.
Daniel

ChangeLog
src/xml.c

index 493d503b38cad7586d3dd189b0be8cd2ed3c6401..3aec6a5502bd796378c81393cee9499712c6256c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Aug 10 15:28:52 CEST 2006 Daniel Veillard <veillard@redhat.com>
+
+       * src/xml.c: markmc pointed out that using number(xpath) could lead
+         to NaN and following comparison would be wrong in a couple of places
+         if the element looked at was missing.
+
 Wed Aug  9 10:17:03 EDT 2006 Daniel Berrange <berrange@redhat.com>
 
        * src/driver.h, src/libvirt.c: Made the virDomainGetXMLDesc
index e4fccd1a7597d27aa7a1062b2a16afef12f6a7a6..619f5127e63079ca8687adbe7659f910324a2dce 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -18,6 +18,7 @@
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #include <libxml/xpath.h>
+#include <math.h> /* for isnan() */
 #include "internal.h"
 #include "hash.h"
 #include "sexpr.h"
@@ -999,7 +1000,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name)
 
     obj = xmlXPathEval(BAD_CAST "number(/domain/memory[1])", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||
-        (obj->floatval < 64000)) {
+        (isnan(obj->floatval)) || (obj->floatval < 64000)) {
         virBufferVSprintf(&buf, "(memory 128)(maxmem 128)");
     } else {
         unsigned long mem = (obj->floatval / 1024);
@@ -1010,7 +1011,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name)
 
     obj = xmlXPathEval(BAD_CAST "number(/domain/vcpu[1])", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||
-        (obj->floatval <= 0)) {
+        (isnan(obj->floatval)) || (obj->floatval <= 0)) {
         virBufferVSprintf(&buf, "(vcpus 1)");
     } else {
         unsigned int cpu = (unsigned int) obj->floatval;