Skip to content

Commit

Permalink
GUACAMOLE-377: Migrate guac_mem_*() assertions to GUAC_ASSERT().
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-jumper committed Jun 11, 2024
1 parent 1c9c07c commit 50d559b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/libguac/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

#include "guacamole/assert.h"
#include "guacamole/error.h"
#include "guacamole/mem.h"
#include "guacamole/private/mem.h"
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 50d559b

Please sign in to comment.