mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-29 09:32:42 +00:00
Add null alloc_addr checks to sys_memory_allocate and sys_memory_allocate_from_container
This commit is contained in:
parent
f4fb5200a0
commit
225310e04b
@ -1,4 +1,4 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "Utilities/VirtualMemory.h"
|
||||
#include "Emu/IdManager.h"
|
||||
#include "sys_memory.h"
|
||||
@ -14,6 +14,8 @@ lv2_memory_alloca::lv2_memory_alloca(u32 size, u32 align, u64 flags, const std::
|
||||
{
|
||||
}
|
||||
|
||||
// Todo: fix order of error checks
|
||||
|
||||
error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr<u32> alloc_addr)
|
||||
{
|
||||
sys_memory.warning("sys_memory_allocate(size=0x%x, flags=0x%llx, alloc_addr=*0x%x)", size, flags, alloc_addr);
|
||||
@ -43,6 +45,12 @@ error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr<u32> alloc_addr)
|
||||
return CELL_ENOMEM;
|
||||
}
|
||||
|
||||
if (!alloc_addr)
|
||||
{
|
||||
dct->used -= size;
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
|
||||
// Allocate memory, write back the start address of the allocated area
|
||||
*alloc_addr = verify(HERE, vm::alloc(size, align == 0x10000 ? vm::user64k : vm::user1m, align));
|
||||
|
||||
@ -90,6 +98,12 @@ error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::
|
||||
return ct.ret;
|
||||
}
|
||||
|
||||
if (!alloc_addr)
|
||||
{
|
||||
ct->used -= size;
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
|
||||
// Create phantom memory object
|
||||
const auto mem = idm::make_ptr<lv2_memory_alloca>(size, align, flags, ct.ptr);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user