utility: Don't crash on nullptr in free_aligned

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2020-07-27 02:17:34 +02:00
parent 56a90db234
commit c1abe07b0f

View file

@ -224,6 +224,8 @@ void util::free_aligned(void* mem)
#elif defined(USE_STD_ALLOC_FREE) #elif defined(USE_STD_ALLOC_FREE)
free(mem); free(mem);
#else #else
if (mem == nullptr)
return;
void* ptr = reinterpret_cast<void*>(*reinterpret_cast<intptr_t*>(static_cast<char*>(mem) - sizeof(void*))); void* ptr = reinterpret_cast<void*>(*reinterpret_cast<intptr_t*>(static_cast<char*>(mem) - sizeof(void*)));
free(ptr); free(ptr);
#endif #endif