summaryrefslogtreecommitdiffstats
path: root/src/game-server
diff options
context:
space:
mode:
authorBertram <yohanndotferreiraatorange.fr>2010-05-12 23:32:41 +0200
committerBertram <yohanndotferreiraatorange.fr>2010-05-12 23:32:41 +0200
commit0a48f0d41653d0a0758fc84fd6a18830bd37da18 (patch)
treec777a1af6b38be51432882323fe0eae57bad23cb /src/game-server
parentcfff8488b15d00d6f7e3e7bf6cf9723c1fe91d0b (diff)
downloadmanaserv-0a48f0d41653d0a0758fc84fd6a18830bd37da18.tar.gz
manaserv-0a48f0d41653d0a0758fc84fd6a18830bd37da18.tar.xz
manaserv-0a48f0d41653d0a0758fc84fd6a18830bd37da18.zip
Fixed a forbidden use of char bomBuffer[utf8Bom.length()]; with ISO C++
Made-by: thorbjorn Reviewed-by: Bertram
Diffstat (limited to 'src/game-server')
-rw-r--r--src/game-server/resourcemanager.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/game-server/resourcemanager.cpp b/src/game-server/resourcemanager.cpp
index 06958e7..3545484 100644
--- a/src/game-server/resourcemanager.cpp
+++ b/src/game-server/resourcemanager.cpp
@@ -134,20 +134,20 @@ char *ResourceManager::loadFile(const std::string &fileName, int &fileSize,
if (removeBOM)
{
- // Inspired by BOMstrip from:
- // Peter Pentchev, 2008, public domain.
- const std::string utf8Bom = "\xef\xbb\xbf";
- char bomBuffer[utf8Bom.length()];
- PHYSFS_read(file, bomBuffer, 1, utf8Bom.length());
+ // Inspired by BOMstrip from Peter Pentchev, 2008, public domain.
+ const char utf8Bom[] = "\xef\xbb\xbf";
+ const int bomLength = sizeof(utf8Bom);
+ char bomBuffer[bomLength];
+ PHYSFS_read(file, bomBuffer, 1, bomLength);
- std::istringstream iss(std::string(bomBuffer, utf8Bom.length()));
+ std::istringstream iss(std::string(bomBuffer, bomLength));
std::string line;
// if we find a BOM, then we remove it from the buffer
if (std::getline(iss, line) && !line.substr(0, 3).compare(utf8Bom))
{
LOG_INFO("Found a Byte Order Mask (BOM) in '" << fileName);
- fileSize = fileSize - utf8Bom.length();
+ fileSize = fileSize - bomLength;
}
else
{
@@ -157,7 +157,7 @@ char *ResourceManager::loadFile(const std::string &fileName, int &fileSize,
}
// Allocate memory and load the file
- char *buffer = (char *)malloc(fileSize + 1);
+ char *buffer = (char *) malloc(fileSize + 1);
if (PHYSFS_read(file, buffer, 1, fileSize) != fileSize)
{
free(buffer);