From d42014f108ece92facea02fb51c549f5065eeaf1 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 10 Aug 2006 14:26:35 +0000 Subject: [PATCH] * 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. Daniel --- ChangeLog | 6 ++++++ src/xml.c | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 493d503b38..3aec6a5502 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Aug 10 15:28:52 CEST 2006 Daniel Veillard + + * 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 * src/driver.h, src/libvirt.c: Made the virDomainGetXMLDesc diff --git a/src/xml.c b/src/xml.c index e4fccd1a75..619f5127e6 100644 --- a/src/xml.c +++ b/src/xml.c @@ -18,6 +18,7 @@ #include #include #include +#include /* 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;