diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/theme.cpp | 55 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_players.cpp | 1 | ||||
-rw-r--r-- | src/resources/db/deaddb.cpp | 10 | ||||
-rw-r--r-- | src/resources/db/itemfielddb.cpp | 7 | ||||
-rw-r--r-- | src/resources/db/questdb.cpp | 3 | ||||
-rw-r--r-- | src/utils/xml/libxml.cpp | 7 |
6 files changed, 59 insertions, 24 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 064bec44f..9fa1b59ec 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -1178,16 +1178,28 @@ ImageSet *Theme::getImageSetFromThemeXml(const std::string &name, } #define readValue(name) \ - info->name = reinterpret_cast<const char*>(\ - XmlNodeGetContent(infoNode)) + { \ + tmpData = reinterpret_cast<char*>( \ + XmlNodeGetContent(infoNode)); \ + info->name = tmpData; \ + XmlFree(tmpData); \ + } #define readIntValue(name) \ - info->name = atoi(reinterpret_cast<const char*>(\ - XmlNodeGetContent(infoNode))) + { \ + tmpData = reinterpret_cast<char*>( \ + XmlNodeGetContent(infoNode)); \ + info->name = atoi(tmpData); \ + XmlFree(tmpData); \ + } #define readFloatValue(name) \ - info->name = static_cast<float>(atof(reinterpret_cast<const char*>(\ - XmlNodeGetContent(infoNode)))) + { \ + tmpData = reinterpret_cast<char*>( \ + XmlNodeGetContent(infoNode)); \ + info->name = static_cast<float>(atof(tmpData)); \ + XmlFree(tmpData); \ + } ThemeInfo *Theme::loadInfo(const std::string &themeName) { @@ -1219,38 +1231,39 @@ ThemeInfo *Theme::loadInfo(const std::string &themeName) const std::string fontSize2("fontSize_" + mScreenDensity); const std::string npcfontSize2("npcfontSize_" + mScreenDensity); + char *tmpData = nullptr; for_each_xml_child_node(infoNode, rootNode) { if (xmlNameEqual(infoNode, "name")) - readValue(name); + readValue(name) else if (xmlNameEqual(infoNode, "copyright")) - readValue(copyright); + readValue(copyright) else if (xmlNameEqual(infoNode, "font")) - readValue(font); + readValue(font) else if (xmlNameEqual(infoNode, "boldFont")) - readValue(boldFont); + readValue(boldFont) else if (xmlNameEqual(infoNode, "particleFont")) - readValue(particleFont); + readValue(particleFont) else if (xmlNameEqual(infoNode, "helpFont")) - readValue(helpFont); + readValue(helpFont) else if (xmlNameEqual(infoNode, "secureFont")) - readValue(secureFont); + readValue(secureFont) else if (xmlNameEqual(infoNode, "npcFont")) - readValue(npcFont); + readValue(npcFont) else if (xmlNameEqual(infoNode, "japanFont")) - readValue(japanFont); + readValue(japanFont) else if (xmlNameEqual(infoNode, "chinaFont")) - readValue(chinaFont); + readValue(chinaFont) else if (xmlNameEqual(infoNode, "fontSize")) - readIntValue(fontSize); + readIntValue(fontSize) else if (xmlNameEqual(infoNode, "npcfontSize")) - readIntValue(npcfontSize); + readIntValue(npcfontSize) else if (xmlNameEqual(infoNode, "guialpha")) - readFloatValue(guiAlpha); + readFloatValue(guiAlpha) else if (xmlNameEqual(infoNode, fontSize2.c_str())) - readIntValue(fontSize); + readIntValue(fontSize) else if (xmlNameEqual(infoNode, npcfontSize2.c_str())) - readIntValue(npcfontSize); + readIntValue(npcfontSize) } doc->decRef(); return info; diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp index ae352d579..ca3506aa4 100644 --- a/src/gui/widgets/tabs/setup_players.cpp +++ b/src/gui/widgets/tabs/setup_players.cpp @@ -171,6 +171,7 @@ Setup_Players::Setup_Players(const Widget2 *const widget) : Setup_Players::~Setup_Players() { delete2(mBadgesList); + delete2(mVisibleNamesList); } void Setup_Players::externalUpdated() diff --git a/src/resources/db/deaddb.cpp b/src/resources/db/deaddb.cpp index 251ae3a33..778d88a0b 100644 --- a/src/resources/db/deaddb.cpp +++ b/src/resources/db/deaddb.cpp @@ -73,11 +73,17 @@ void DeadDB::loadXmlFile(const std::string &fileName, } else if (xmlNameEqual(node, "message")) { - const char *const data = reinterpret_cast<const char*>( + char *const data = reinterpret_cast<char*>( XmlNodeGetContent(node)); - if (!data || !*data) + if (!data) continue; + if (!*data) + { + XmlFree(data); + continue; + } mMessages.push_back(data); + XmlFree(data); } } diff --git a/src/resources/db/itemfielddb.cpp b/src/resources/db/itemfielddb.cpp index 17f9b61e1..0eeb7f901 100644 --- a/src/resources/db/itemfielddb.cpp +++ b/src/resources/db/itemfielddb.cpp @@ -86,6 +86,13 @@ static void loadFields(const XmlNodePtr groupNode, name.c_str()); continue; } + if (fields1.find(name) != fields1.end()) + { + reportAlways( + "Same field name detected: %s", + name.c_str()); + continue; + } fields1[name] = new ItemFieldType(name, description, sign); diff --git a/src/resources/db/questdb.cpp b/src/resources/db/questdb.cpp index 93bcada6e..da05721b1 100644 --- a/src/resources/db/questdb.cpp +++ b/src/resources/db/questdb.cpp @@ -83,11 +83,12 @@ static void loadQuest(const int var, { if (!xmlTypeEqual(dataNode, XML_ELEMENT_NODE)) continue; - const char *const data = reinterpret_cast<const char*>( + char *const data = reinterpret_cast<char*>( XmlNodeGetContent(dataNode)); if (!data) continue; std::string str = translator->getStr(data); + XmlFree(data); for (int f = 1; f < 100; f ++) { diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp index c19255b24..b85e456f4 100644 --- a/src/utils/xml/libxml.cpp +++ b/src/utils/xml/libxml.cpp @@ -250,9 +250,16 @@ namespace XML xmlChar *const prop = XmlGetProp(node, name); if (XmlStrEqual(prop, "true")) + { + XmlFree(prop); return true; + } if (XmlStrEqual(prop, "false")) + { + XmlFree(prop); return false; + } + XmlFree(prop); return def; } |