Skip to content

Commit

Permalink
memory_grow_impl: use overflow checking macro
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jul 25, 2024
1 parent d9784ff commit 0175981
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/exec_insn_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,11 @@ memory_grow_impl(struct exec_context *ctx, struct meminst *mi, uint32_t sz)
retry:
#endif
orig_size = mi->size_in_pages;
if (sz > UINT32_MAX - orig_size) {
uint32_t new_size;
if (ADD_U32_OVERFLOW(orig_size, sz, &new_size)) {
memory_unlock(mi);
return (uint32_t)-1; /* fail */
}
uint32_t new_size = orig_size + sz;
assert(lim->max <= WASM_MAX_MEMORY_SIZE >> page_shift);
if (new_size > lim->max) {
memory_unlock(mi);
Expand Down

0 comments on commit 0175981

Please sign in to comment.