From 756f05c0acf18feefaf5a83dab9daaa8fd172dbc Mon Sep 17 00:00:00 2001 From: dorjoy03 Date: Sun, 15 Oct 2023 22:46:23 +0600 Subject: [PATCH] elasticarray: remove redundant checks --- libcperciva/datastruct/elasticarray.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libcperciva/datastruct/elasticarray.c b/libcperciva/datastruct/elasticarray.c index e157c8f9..b474ff66 100644 --- a/libcperciva/datastruct/elasticarray.c +++ b/libcperciva/datastruct/elasticarray.c @@ -161,8 +161,7 @@ elasticarray_append(struct elasticarray * EA, size_t nsize; /* Check for overflow. */ - if ((nrec > SIZE_MAX / reclen) || - (nrec * reclen > SIZE_MAX - EA->size)) { + if (nrec > ((SIZE_MAX - EA->size) / reclen)) { errno = ENOMEM; goto err0; } @@ -205,8 +204,7 @@ elasticarray_shrink(struct elasticarray * EA, size_t nrec, size_t reclen) size_t nsize; /* Figure out how much to keep. */ - if ((nrec > SIZE_MAX / reclen) || - (nrec * reclen > EA->size)) + if (nrec > EA->size / reclen) nsize = 0; else nsize = EA->size - nrec * reclen;