浏览代码

Added Sanity Check for out of memory

Vincent Gee 11 年之前
父节点
当前提交
a849202bde
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      Engine/source/core/volume.cpp

+ 10 - 0
Engine/source/core/volume.cpp

@@ -944,12 +944,22 @@ bool ReadFile(const Path &inPath, void *&outData, U32 &outSize, bool inNullTermi
    if ( inNullTerminate )
    {
       outData = new char [outSize+1];
+      if( !outData )
+      {
+          // out of memory
+          return false;
+      }
       sizeRead = fileR->read(outData, outSize);
       static_cast<char *>(outData)[outSize] = '\0';
    }
    else
    {
       outData = new char [outSize];
+      if( !outData )
+      {
+          // out of memory
+          return false;
+      }
       sizeRead = fileR->read(outData, outSize);
    }