From 9f083b80700c52dfbc50b293189a09c090bdf099 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 8 Jun 2024 13:41:46 -0700 Subject: [PATCH] GUACAMOLE-377: Migrate guac_mem_*() assertions to GUAC_ASSERT(). --- src/libguac/mem.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/libguac/mem.c b/src/libguac/mem.c index 8f9a842a6..06735bf00 100644 --- a/src/libguac/mem.c +++ b/src/libguac/mem.c @@ -17,6 +17,7 @@ * under the License. */ +#include "guacamole/assert.h" #include "guacamole/error.h" #include "guacamole/mem.h" #include "guacamole/private/mem.h" @@ -126,8 +127,7 @@ size_t PRIV_guac_mem_ckd_mul_or_die(size_t factor_count, const size_t* factors) /* Perform request multiplication, aborting the entire process if the * calculation overflows */ size_t result = 0; - if (PRIV_guac_mem_ckd_mul(&result, factor_count, factors)) - abort(); + GUAC_ASSERT(!PRIV_guac_mem_ckd_mul(&result, factor_count, factors)); return result; @@ -138,8 +138,7 @@ size_t PRIV_guac_mem_ckd_add_or_die(size_t term_count, const size_t* terms) { /* Perform request addition, aborting the entire process if the calculation * overflows */ size_t result = 0; - if (PRIV_guac_mem_ckd_add(&result, term_count, terms)) - abort(); + GUAC_ASSERT(!PRIV_guac_mem_ckd_add(&result, term_count, terms)); return result; @@ -150,8 +149,7 @@ size_t PRIV_guac_mem_ckd_sub_or_die(size_t term_count, const size_t* terms) { /* Perform request subtraction, aborting the entire process if the * calculation overflows */ size_t result = 0; - if (PRIV_guac_mem_ckd_sub(&result, term_count, terms)) - abort(); + GUAC_ASSERT(!PRIV_guac_mem_ckd_sub(&result, term_count, terms)); return result; @@ -238,8 +236,7 @@ void* PRIV_guac_mem_realloc_or_die(void* mem, size_t factor_count, const size_t* /* Perform requested resize, aborting the entire process if this cannot be * done */ void* resized_mem = PRIV_guac_mem_realloc(mem, factor_count, factors); - if (resized_mem == NULL && guac_error != GUAC_STATUS_SUCCESS) - abort(); + GUAC_ASSERT(resized_mem != NULL || guac_error == GUAC_STATUS_SUCCESS); return resized_mem;