diff options
Diffstat (limited to 'lib/util/alloc.c')
-rw-r--r-- | lib/util/alloc.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/util/alloc.c b/lib/util/alloc.c index 2d748a7..8e1c4f1 100644 --- a/lib/util/alloc.c +++ b/lib/util/alloc.c @@ -16,12 +16,8 @@ void *alloc_flex(size_t base_size, size_t item_size, size_t nmemb) { size_t size; - if (SZ_MUL_OV(nmemb, item_size, &size)) { - errno = EOVERFLOW; - return NULL; - } - - if (SZ_ADD_OV(base_size, size, &size)) { + if (SZ_MUL_OV(nmemb, item_size, &size) || + SZ_ADD_OV(base_size, size, &size)) { errno = EOVERFLOW; return NULL; } |