mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-08 01:00:11 +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 changed files with 15 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Utilities/VirtualMemory.h"
|
#include "Utilities/VirtualMemory.h"
|
||||||
#include "Emu/IdManager.h"
|
#include "Emu/IdManager.h"
|
||||||
#include "sys_memory.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)
|
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);
|
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;
|
return CELL_ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!alloc_addr)
|
||||||
|
{
|
||||||
|
dct->used -= size;
|
||||||
|
return CELL_EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate memory, write back the start address of the allocated area
|
// 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));
|
*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;
|
return ct.ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!alloc_addr)
|
||||||
|
{
|
||||||
|
ct->used -= size;
|
||||||
|
return CELL_EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
// Create phantom memory object
|
// Create phantom memory object
|
||||||
const auto mem = idm::make_ptr<lv2_memory_alloca>(size, align, flags, ct.ptr);
|
const auto mem = idm::make_ptr<lv2_memory_alloca>(size, align, flags, ct.ptr);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue