Skip to content

Commit

Permalink
array_extend: use MUL_SIZE_OVERFLOW
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jul 19, 2024
1 parent abae380 commit 7114c4c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ array_extend(struct mem_context *mctx, void **p, size_t elem_size,
return 0;
}
const size_t old_bytesize = elem_size * old_elem_count;
const size_t bytesize = elem_size * new_elem_count;
if (bytesize / elem_size != new_elem_count) {
size_t bytesize;
if (MUL_SIZE_OVERFLOW(elem_size, new_elem_count, &bytesize)) {
return EOVERFLOW;
}
np = mem_extend(mctx, *p, old_bytesize, bytesize);
Expand Down

0 comments on commit 7114c4c

Please sign in to comment.