11 lines
230 B
C
11 lines
230 B
C
#include "beware_overflow.h"
|
|
|
|
void *beware_overflow(void *ptr, size_t nmemb, size_t size)
|
|
{
|
|
size_t c;
|
|
if (__builtin_mul_overflow(nmemb, size, &c))
|
|
return NULL;
|
|
|
|
char *byte_ptr = ptr;
|
|
return c + byte_ptr;
|
|
}
|