diff --git a/src/libev/ev.c b/src/libev/ev.c index c4a007023..1102c94ec 100644 --- a/src/libev/ev.c +++ b/src/libev/ev.c @@ -2256,10 +2256,10 @@ array_nextsize (int elem, int cur, int cnt) while (cnt > ncur); /* if size is large, round to MALLOC_ROUND - 4 * longs to accommodate malloc overhead */ - if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) + if ((size_t)elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) { ncur *= elem; - ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); + ncur = ((size_t)ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); ncur = ncur - sizeof (void *) * 4; ncur /= elem; } @@ -2272,7 +2272,7 @@ static void * array_realloc (int elem, void *base, int *cur, int cnt) { *cur = array_nextsize (elem, *cur, cnt); - return ev_realloc (base, elem * *cur); + return ev_realloc (base, (size_t)elem * *cur); } #define array_needsize_noinit(base,offset,count)