icinga2/lib/base/allocator.cpp
Alexander A. Klimov 7a21001d6d malloc(): call actual malloc(3)
PoC: Icinga works again.
2023-08-28 15:54:07 +02:00

21 lines
402 B
C++

/* Icinga 2 | (c) 2023 Icinga GmbH | GPLv2+ */
#ifndef _WIN32
#include <cstddef>
#include <dlfcn.h>
extern "C" void* malloc(size_t bytes)
{
static const auto libcMalloc = (void*(*)(size_t))dlsym(RTLD_NEXT, "malloc");
return libcMalloc(bytes);
}
extern "C" void free(void* memory)
{
static const auto libcFree = (void(*)(void*))dlsym(RTLD_NEXT, "free");
libcFree(memory);
}
#endif /* _WIN32 */