1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

LibWasm: Use the number of bytes when comparing memory limits

...instead of comparing page count with byte count.
This commit is contained in:
Ali Mohammad Pur 2021-07-06 12:05:29 +04:30 committed by Ali Mohammad Pur
parent 4bdb0ad132
commit 0b08392e54

View file

@ -350,8 +350,10 @@ public:
if (size_to_grow == 0) if (size_to_grow == 0)
return true; return true;
auto new_size = m_data.size() + size_to_grow; auto new_size = m_data.size() + size_to_grow;
if (m_type.limits().max().value_or(new_size) < new_size) if (auto max = m_type.limits().max(); max.has_value()) {
if (max.value() * Constants::page_size < new_size)
return false; return false;
}
auto previous_size = m_size; auto previous_size = m_size;
m_data.resize(new_size); m_data.resize(new_size);
m_size = new_size; m_size = new_size;