From 12c56ffc954e4cde72c43174ebd11ccd0d523c1e Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Wed, 26 Nov 2025 14:03:09 +0100 Subject: [PATCH] upcast int to size_t to prevent overflow --- modules/libcom/src/flex/misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/libcom/src/flex/misc.c b/modules/libcom/src/flex/misc.c index 689f7cdcf..edc35ecd9 100644 --- a/modules/libcom/src/flex/misc.c +++ b/modules/libcom/src/flex/misc.c @@ -76,7 +76,7 @@ void *allocate_array(int size, int element_size) if ( element_size * size <= 0 ) flexfatal( "request for < 1 byte in allocate_array()" ); - mem = malloc( element_size * size ); + mem = malloc( (size_t) element_size * size ); if ( mem == NULL ) flexfatal( "memory allocation failed in allocate_array()" ); @@ -705,7 +705,7 @@ void *reallocate_array(void *array, int size, int element_size) flexfatal( "attempt to increase array size by less than 1 byte" ); new_array = - realloc( array, size * element_size ); + realloc( array, (size_t) size * element_size ); if ( new_array == NULL ) flexfatal( "attempt to increase array size failed" );