diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index e709c7f25f..e898b6e201 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -1544,7 +1544,7 @@ void ppu_load_exec(const ppu_exec_object& elf) case 0x70: primary_stacksize = 1024 * 1024; break; // SYS_PROCESS_PRIMARY_STACK_SIZE_1M default: { - primary_stacksize = sz >= 4096 ? ::align(std::min(sz, 0x100000), 4096) : 0x4000; + primary_stacksize = ::align(std::clamp(sz, 0x10000, 0x100000), 4096); break; } } diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index 9c03369eb2..9aa0a9d200 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -307,7 +307,7 @@ error_code _sys_ppu_thread_create(vm::ptr thread_id, vm::ptr= 4096 ? ::align(std::min(_stacksz, 0x100000), 4096) : 0x4000; + const u32 stack_size = ::align(std::max(_stacksz, 4096), 4096); const vm::addr_t stack_base{vm::alloc(stack_size, vm::stack, 4096)}; diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index e8cdbcb0dd..063577b868 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -709,7 +709,7 @@ namespace vm } // Return if size is invalid - if (!orig_size || !size || size > this->size) + if (!orig_size || !size || orig_size > size || size > this->size) { return 0; } @@ -764,7 +764,7 @@ namespace vm const u32 size = ::align(orig_size, min_page_size); // return if addr or size is invalid - if (!size || addr < this->addr || addr + u64{size} > this->addr + u64{this->size} || flags & 0x10) + if (!size || addr < this->addr || orig_size > size || addr + u64{size} > this->addr + u64{this->size} || flags & 0x10) { return 0; }