mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-01-06 08:40:28 +01:00
[orbis-kernel] Check overflow in kalloc
This commit is contained in:
parent
0e3cbd6627
commit
3c3fcaaea4
|
|
@ -100,6 +100,11 @@ void *KernelContext::kalloc(std::size_t size, std::size_t align) {
|
|||
heap = (heap + (align - 1)) & ~(align - 1);
|
||||
auto result = reinterpret_cast<void *>(heap);
|
||||
m_heap_next = reinterpret_cast<void *>(heap + size);
|
||||
// Check overflow
|
||||
if (heap + size < heap)
|
||||
std::abort();
|
||||
if (heap + size > (uintptr_t)&g_context + 0x1'0000'0000)
|
||||
std::abort();
|
||||
pthread_mutex_unlock(&m_heap_mtx);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue