mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-07-18 01:41:02 +00:00
Lib.Kernel: Check to ensure heap_api is valid before running heap mallocs in TlsGetAddr (#4709)
* Check to ensure heap_api is valid before running heap mallocs in TlsGetAddr * Obligatory clang commit * Linux
This commit is contained in:
@@ -459,7 +459,12 @@ void* Linker::TlsGetAddr(u64 module_index, u64 offset) {
|
||||
if (!addr) {
|
||||
// Module was just loaded by above code. Allocate TLS block for it.
|
||||
const u32 init_image_size = module->tls.init_image_size;
|
||||
u8* dest = reinterpret_cast<u8*>(heap_api->heap_malloc(module->tls.image_size));
|
||||
u8* dest{};
|
||||
if (heap_api && heap_api->heap_malloc) {
|
||||
dest = reinterpret_cast<u8*>(heap_api->heap_malloc(module->tls.image_size));
|
||||
} else {
|
||||
dest = reinterpret_cast<u8*>(std::malloc(module->tls.image_size));
|
||||
}
|
||||
const u8* src = reinterpret_cast<const u8*>(module->tls.image_virtual_addr);
|
||||
std::memcpy(dest, src, init_image_size);
|
||||
std::memset(dest + init_image_size, 0, module->tls.image_size - init_image_size);
|
||||
|
||||
Reference in New Issue
Block a user