Преглед изворни кода

Merge pull request #6853 from ghalliday/issue12870

HPCC-12870 Allow arrays to allocate > 4Gb of memory

Reviewed-By:Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman пре 10 година
родитељ
комит
acd814b473
1 измењених фајлова са 7 додато и 1 уклоњено
  1. 7 1
      system/jlib/jarray.cpp

+ 7 - 1
system/jlib/jarray.cpp

@@ -86,7 +86,13 @@ void Allocator::_reallocate(aindex_t newLen, size32_t itemSize)
         while (newLen > newMax)
             newMax += newMax;
     }
-    void *newhead = realloc(_head, itemSize * newMax);
+    size_t allocSize = (size_t)itemSize * newMax;
+    if (allocSize < newMax)
+    {
+        PrintLog("Out of memory (overflow) in Array allocator: itemSize = %d, trying to allocate %d items", itemSize, newLen);
+        throw MakeStringException(0, "Out of memory (overflow) in Array allocator: itemSize = %u, trying to allocate %u items",itemSize, newLen);
+    }
+    void *newhead = realloc(_head, allocSize);
     if (!newhead) 
     {
         PrintLog("Out of memory in Array allocator: itemSize = %d, trying to allocate %d items", itemSize, max);