summaryrefslogtreecommitdiff
path: root/src/utils/xml.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-09-27 22:40:40 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-09-27 22:40:40 +0200
commit6f25f5d9390ae247970ad886dc51d55435285831 (patch)
treee5c748d1e5598cdd658741a4b35890cec636d37a /src/utils/xml.cpp
parent661d16e98c62dfff40f481177bf3f1a0c58c2124 (diff)
downloadmana-6f25f5d9390ae247970ad886dc51d55435285831.tar.gz
mana-6f25f5d9390ae247970ad886dc51d55435285831.tar.bz2
mana-6f25f5d9390ae247970ad886dc51d55435285831.tar.xz
mana-6f25f5d9390ae247970ad886dc51d55435285831.zip
Centralized String to bool conversion into the client.
The former XML::getBoolProperty() had a potential memleak and was unsafe when dealing with unknown values. Reviewed-by: CodyMartin. Resolves: Mana-Mantis #213.
Diffstat (limited to 'src/utils/xml.cpp')
-rw-r--r--src/utils/xml.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 2bcb6f24..65eb1370 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -32,6 +32,7 @@
#include "resources/resourcemanager.h"
+#include "utils/stringutils.h"
#include "utils/zlib.h"
namespace XML
@@ -135,11 +136,14 @@ namespace XML
bool getBoolProperty(xmlNodePtr node, const char* name, bool def)
{
+ bool ret = def;
xmlChar *prop = xmlGetProp(node, BAD_CAST name);
-
- if (xmlStrEqual(prop, BAD_CAST "true" ) ) return true;
- if (xmlStrEqual(prop, BAD_CAST "false") ) return false;
- return def;
+ if (prop)
+ {
+ ret = getBoolFromString((char*) prop, def);
+ xmlFree(prop);
+ }
+ return ret;
}
xmlNodePtr findFirstChildByName(xmlNodePtr parent, const char *name)