Use reallocarray() in sc_vector

This fails safely in case of overflow.
This commit is contained in:
Romain Vimont 2023-02-28 21:49:44 +01:00
parent 6dceb32817
commit c735b8c127

View file

@ -118,7 +118,7 @@ static inline void *
sc_vector_reallocdata_(void *ptr, size_t count, size_t size, sc_vector_reallocdata_(void *ptr, size_t count, size_t size,
size_t *restrict pcap, size_t *restrict psize) size_t *restrict pcap, size_t *restrict psize)
{ {
void *p = realloc(ptr, count * size); void *p = reallocarray(ptr, count, size);
if (!p) { if (!p) {
return NULL; return NULL;
} }