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

Do not allow WebAssemblyArrayBuffer to be detached by anything other than GrowMemory

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

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

@@ -1038,6 +1038,11 @@ namespace Js
 #endif
     }
 
+    ArrayBufferDetachedStateBase* WebAssemblyArrayBuffer::CreateDetachedState(BYTE* buffer, uint32 bufferLength)
+    {
+        JavascriptError::ThrowTypeError(GetScriptContext(), WASMERR_CantDetach);
+    }
+
     WebAssemblyArrayBuffer* WebAssemblyArrayBuffer::GrowMemory(uint32 newBufferLength)
     {
         if (newBufferLength < this->bufferLength)

+ 3 - 0
lib/Runtime/Library/ArrayBuffer.h

@@ -297,6 +297,9 @@ namespace Js
         virtual bool IsValidVirtualBufferLength(uint length) const override;
         virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) override;
         virtual bool IsWebAssemblyArrayBuffer() override { return true; }
+
+    protected:
+        virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, DECLSPEC_GUARD_OVERFLOW uint32 bufferLength) override;
     };
 
     // the memory must be allocated via CoTaskMemAlloc.