added double free detection
This commit is contained in:
parent
e02042cade
commit
04212c3d55
10
src/util.c
10
src/util.c
|
@ -133,15 +133,19 @@ void *CALLOC(size_t nmemb, size_t size)
|
|||
{
|
||||
void *ptr = calloc(nmemb, size);
|
||||
if (!ptr) {
|
||||
lprintf(fatal, "calloc() failed, %s!\n", strerror(errno));
|
||||
lprintf(fatal, "%s!\n", strerror(errno));
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void FREE(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
if (ptr) {
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
} else {
|
||||
lprintf(fatal, "attempted to double free a pointer!\n");
|
||||
}
|
||||
}
|
||||
|
||||
char *str_to_hex(char *s)
|
||||
|
|
Loading…
Reference in New Issue