Skip to content

Commit dfcadc6

Browse files
TianlongLiangloganek
authored andcommitted
prevent data overflow on 32 bit platform for memory.grow
1 parent d9c01b3 commit dfcadc6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/iwasm/common/wasm_memory.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,12 @@ wasm_mremap_linear_memory(void *mapped_mem, uint64 old_size, uint64 new_size,
12531253
bh_assert(new_size > 0);
12541254
bh_assert(new_size > old_size);
12551255

1256+
#if UINTPTR_MAX == UINT32_MAX
1257+
if (new_size == 4 * (uint64)BH_GB) {
1258+
return NULL;
1259+
}
1260+
#endif
1261+
12561262
if (mapped_mem) {
12571263
new_mem = os_mremap(mapped_mem, old_size, new_size);
12581264
}

0 commit comments

Comments
 (0)