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