diff --git a/src/parser/WASMParser.cpp b/src/parser/WASMParser.cpp index 75c816864..eaed0d442 100644 --- a/src/parser/WASMParser.cpp +++ b/src/parser/WASMParser.cpp @@ -530,10 +530,11 @@ class WASMBinaryReader : public wabt::WASMBinaryReaderDelegate { } m_vmStack.push_back(VMStackInfo(*this, type, pos, m_functionStackSizeSoFar, localIndex)); - m_functionStackSizeSoFar += Walrus::valueStackAllocatedSize(type); - if (UNLIKELY(m_functionStackSizeSoFar > std::numeric_limits::max())) { + size_t allocSize = Walrus::valueStackAllocatedSize(type); + if (UNLIKELY(m_functionStackSizeSoFar + allocSize > std::numeric_limits::max())) { throw std::string("too many stack usage. we could not support this(yet)."); } + m_functionStackSizeSoFar += allocSize; m_currentFunction->m_requiredStackSize = std::max( m_currentFunction->m_requiredStackSize, m_functionStackSizeSoFar); } diff --git a/src/runtime/Memory.cpp b/src/runtime/Memory.cpp index 9903d48a2..a11518c64 100644 --- a/src/runtime/Memory.cpp +++ b/src/runtime/Memory.cpp @@ -41,7 +41,7 @@ Memory::Memory(uint64_t initialSizeInByte, uint64_t maximumSizeInByte) , m_maximumSizeInByte(maximumSizeInByte) , m_buffer(nullptr) { - RELEASE_ASSERT(initialSizeInByte <= std::numeric_limits::max()); + ASSERT(initialSizeInByte <= std::numeric_limits::max()); #if defined(WALRUS_USE_MMAP) if (m_maximumSizeInByte) { #ifndef WALRUS_32_MEMORY_INITIAL_MMAP_RESERVED_ADDRESS_SIZE diff --git a/src/shell/Shell.cpp b/src/shell/Shell.cpp index 3ee5485ca..34cc33a65 100644 --- a/src/shell/Shell.cpp +++ b/src/shell/Shell.cpp @@ -655,8 +655,9 @@ static void executeWAST(Store* store, const std::string& filename, const std::ve auto result = wabt::ParseWastScript(lexer.get(), &script, &errors, &parse_wast_options); if (!wabt::Succeeded(result)) { printf("Syntax error(s):\n"); - for (auto e : errors) + for (auto& e : errors) { printf(" %s\n", e.message.c_str()); + } printf("\n"); RELEASE_ASSERT_NOT_REACHED(); } @@ -1000,7 +1001,7 @@ int main(int argc, char* argv[]) FILE* fp = fopen(filePath.data(), "r"); if (fp) { fseek(fp, 0, SEEK_END); - auto sz = ftell(fp); + size_t sz = ftell(fp); fseek(fp, 0, SEEK_SET); std::vector buf; buf.resize(sz); @@ -1008,7 +1009,7 @@ int main(int argc, char* argv[]) fclose(fp); // read again with binary mode if result is not success // this one needs for windows - if (ret != sz) { + if (UNLIKELY((size_t)ret != sz)) { FILE* fp = fopen(filePath.data(), "rb"); fread(buf.data(), sz, 1, fp); fclose(fp);