From 3d24adb1162c4ce1b5030b73ea72873a2b14f6f9 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 15 Mar 2015 17:06:52 -0400 Subject: Fixed bug with map with no name --- src/map.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index 6b83442..ef0d6c3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -44,8 +44,14 @@ Map::Map(const std::string name) if (!xmlStrcmp(node->name, (const xmlChar*) "name")) { xmlChar* key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1); - title = (char*) calloc(xmlStrlen(key) + 1, sizeof(char)); - strcpy(title, (char*) key); + int len = xmlStrlen(key); + title = (char*) calloc(len + 1, sizeof(char)); + + if (len > 0) + { + strcpy(title, (char*) key); + } + xmlFree(key); } else if (!xmlStrcmp(node->name, (const xmlChar*) "environment")) { -- cgit 1.4.1