From b80dc4d6e076ae0d60de7994f15fa39dfa4a6ee9 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Tue, 8 Feb 2011 21:05:31 -0200 Subject: [PATCH] fix load text bug --- src/framework/configmanager.cpp | 3 +-- src/framework/resourcemanager.cpp | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/framework/configmanager.cpp b/src/framework/configmanager.cpp index 818a6b3a..e3494357 100644 --- a/src/framework/configmanager.cpp +++ b/src/framework/configmanager.cpp @@ -58,12 +58,11 @@ bool ConfigManager::load(const std::string& fileName) YAML::Node doc; parser.GetNextDocument(doc); - for(YAML::Iterator it = doc.begin(); it != doc.end(); it++) { + for(YAML::Iterator it = doc.begin(); it != doc.end(); ++it) { std::string key, value; it.first() >> key; it.second() >> value; m_confsMap[key] = value; - dump() << key << value; } } catch (YAML::ParserException& e) { error("Malformed configuration file!"); diff --git a/src/framework/resourcemanager.cpp b/src/framework/resourcemanager.cpp index 356fc93f..b6ba46b4 100644 --- a/src/framework/resourcemanager.cpp +++ b/src/framework/resourcemanager.cpp @@ -81,8 +81,9 @@ unsigned char *ResourceManager::loadFile(const std::string& fileName, unsigned i } *fileSize = PHYSFS_fileLength(file); - unsigned char *buffer = new unsigned char[*fileSize]; + unsigned char *buffer = new unsigned char[*fileSize + 1]; PHYSFS_read(file, (void*)buffer, 1, *fileSize); + buffer[*fileSize] = 0; PHYSFS_close(file); return buffer; }