2
0
Michael Ferris 8 жил өмнө
parent
commit
e3a8ebc024

+ 4 - 2
lib/Common/Memory/HeapAllocator.h

@@ -103,8 +103,9 @@ struct HeapAllocator
         {
             HeapDelete(obj);
         }
-        void Replace(T* obj)
+        void Set(T* obj)
         {
+            Assert(this->obj == nullptr);
             this->obj = obj;
         }
         void Release()
@@ -128,8 +129,9 @@ struct HeapAllocator
         {
             HeapDeleteArray(count, obj);
         }
-        void Replace(__ecount(count) T* obj, size_t count)
+        void Set(__ecount(count) T* obj, size_t count)
         {
+            Assert(this->obj == nullptr);
             this->obj = obj;
             this->count = count;
         }

+ 2 - 2
lib/Runtime/Library/WebAssemblyModule.cpp

@@ -825,7 +825,7 @@ char16* WebAssemblyModule::FormatExceptionMessage(Wasm::WasmCompilationException
     {
         size_t len = wcslen(originalExceptionMessage) + 1;
         char16* buf = HeapNewArray(char16, len);
-        autoFree->Replace(buf, len);
+        autoFree->Set(buf, len);
         js_memcpy_s(buf, len * sizeof(char16), originalExceptionMessage, len * sizeof(char16));
         return buf;
     }
@@ -835,7 +835,7 @@ char16* WebAssemblyModule::FormatExceptionMessage(Wasm::WasmCompilationException
     const char16* format = _u("function %s at offset %u/%u (0x%x/0x%x): %s");
     const char16* funcName = body->GetDisplayName();
     char16* buf = HeapNewArray(char16, 2048);
-    autoFree->Replace(buf, 2048);
+    autoFree->Set(buf, 2048);
 
     _snwprintf_s(buf, 2048, _TRUNCATE, format,
         funcName,