If uses of dlopen(), e.g. when loading plugins, produce errors an error
string could get allocated dynamically. At this point realloc() might not
yet be resolved and when dlsym() is later called by leak detective to do
so the error string might get freed while leak detective is disabled and
real_free() will be called with a pointer into one of leak detective's
memory blocks instead of a pointer to the block itself, causing a SIGSEGV.
#define HOOK(ret, name, ...) ret name(__VA_ARGS__)
/**
- * Hook initialization when not using hooks
+ * Hook initialization when not using hooks, resolve functions.
*/
static bool register_hooks()
{
+ void *buf = real_malloc(8);
+ real_realloc(buf, 16);
+ real_free(buf);
return TRUE;
}