From 0b08392e5416ddbd1694a3a31b911f7bbc81020e Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Tue, 6 Jul 2021 12:05:29 +0430 Subject: [PATCH] LibWasm: Use the number of bytes when comparing memory limits ...instead of comparing page count with byte count. --- .../Libraries/LibWasm/AbstractMachine/AbstractMachine.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h index 3302b148fa5..95cc31771bf 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h @@ -350,8 +350,10 @@ public: if (size_to_grow == 0) return true; auto new_size = m_data.size() + size_to_grow; - if (m_type.limits().max().value_or(new_size) < new_size) - return false; + if (auto max = m_type.limits().max(); max.has_value()) { + if (max.value() * Constants::page_size < new_size) + return false; + } auto previous_size = m_size; m_data.resize(new_size); m_size = new_size;