Commit 5c209f7d authored by Robert Menzel's avatar Robert Menzel
Browse files

fixed a bug in the memory allocation

parent 0469d2c4
......@@ -30,11 +30,15 @@ bool FileOperations::rawData(const std::string& _filename, char*& _pData, long_t
_size = ftell(pFile);
rewind(pFile);
try
{
// allocate memory to contain the whole file:
_pData = new char[sizeof(char)*_size];
if(_pData == NULL)
_pData = new char[_size];
}
catch(...)
{
error() << "Memory error!" << std::endl;
fclose (pFile);
return false;
}
......@@ -43,6 +47,7 @@ bool FileOperations::rawData(const std::string& _filename, char*& _pData, long_t
if ( (long_t)result != _size)
{
error() << "Reading error!" << std::endl;
fclose (pFile);
return false;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment