From d69c8e1bccaf383a73bf2c122794cfc467f4b6e7 Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Mon, 22 Oct 2007 19:07:38 +0000 Subject: Plugged memory leak. Cleaned code. --- src/configuration.cpp | 13 ++++++------- src/main.cpp | 4 ++++ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/configuration.cpp b/src/configuration.cpp index d33df386..864ad7c3 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -53,6 +53,7 @@ void Configuration::init(const std::string &filename) if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration")) { logger->log("Warning: No configuration file (%s)", filename.c_str()); + xmlFreeDoc(doc); return; } @@ -61,15 +62,13 @@ void Configuration::init(const std::string &filename) if (!xmlStrEqual(node->name, BAD_CAST "option")) continue; - xmlChar *name = xmlGetProp(node, BAD_CAST "name"); - xmlChar *value = xmlGetProp(node, BAD_CAST "value"); + std::string name = XML::getProperty(node, "name", std::string()); + std::string value = XML::getProperty(node, "value", std::string()); - if (name && value) { - mOptions[(const char*)name] = (const char*)value; + if (!name.empty() && !value.empty()) + { + mOptions[name] = value; } - - if (name) xmlFree(name); - if (value) xmlFree(value); } xmlFreeDoc(doc); diff --git a/src/main.cpp b/src/main.cpp index 19fa9150..c7c4683c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1053,6 +1053,10 @@ int main(int argc, char *argv[]) logger->log("Exception"); } +#ifdef PACKAGE_VERSION + delete versionLabel; +#endif + accountServerConnection->disconnect(); gameServerConnection->disconnect(); chatServerConnection->disconnect(); -- cgit v1.2.3-70-g09d2