Просмотр исходного кода

Handle case when growing memory of 0 bytes

Michael Ferris 9 лет назад
Родитель
Сommit
2c70ea6ce7
2 измененных файлов с 9 добавлено и 0 удалено
  1. 4 0
      lib/Runtime/Library/ArrayBuffer.cpp
  2. 5 0
      lib/Runtime/Library/WebAssemblyMemory.cpp

+ 4 - 0
lib/Runtime/Library/ArrayBuffer.cpp

@@ -865,6 +865,10 @@ namespace Js
 
     ArrayBuffer * WebAssemblyArrayBuffer::TransferInternal(uint32 newBufferLength)
     {
+        if (newBufferLength == this->bufferLength)
+        {
+            return this;
+        }
 #if ENABLE_FAST_ARRAYBUFFER
         ReportDifferentialAllocation(newBufferLength);
         Assert(this->buffer);

+ 5 - 0
lib/Runtime/Library/WebAssemblyMemory.cpp

@@ -133,6 +133,11 @@ WebAssemblyMemory::GrowInternal(uint32 deltaPages)
     const uint32 oldPageCount = oldBytes / WebAssembly::PageSize;
     Assert(oldBytes % WebAssembly::PageSize == 0);
 
+    if (deltaBytes == 0)
+    {
+        return (int32)oldPageCount;
+    }
+
     const uint32 newPageCount = oldPageCount + deltaPages;
     if (newPageCount > m_maximum)
     {