diff --git a/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp b/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp index bce53764d2..07f57a7d78 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp @@ -410,11 +410,6 @@ error_code sys_event_flag_get(ppu_thread& ppu, u32 id, vm::ptr flags) sys_event_flag.trace("sys_event_flag_get(id=0x%x, flags=*0x%x)", id, flags); - if (!flags) - { - return CELL_EFAULT; - } - const auto flag = idm::check(id, [](lv2_event_flag& flag) { return +flag.pattern; @@ -422,10 +417,15 @@ error_code sys_event_flag_get(ppu_thread& ppu, u32 id, vm::ptr flags) if (!flag) { - *flags = 0; + if (flags) *flags = 0; return CELL_ESRCH; } + if (!flags) + { + return CELL_EFAULT; + } + *flags = flag.ret; return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp b/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp index 9ad520d306..93621241eb 100644 --- a/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp @@ -265,11 +265,6 @@ error_code sys_semaphore_get_value(ppu_thread& ppu, u32 sem_id, vm::ptr cou sys_semaphore.trace("sys_semaphore_get_value(sem_id=0x%x, count=*0x%x)", sem_id, count); - if (!count) - { - return CELL_EFAULT; - } - const auto sema = idm::check(sem_id, [](lv2_sema& sema) { return std::max(0, sema.val); @@ -280,6 +275,11 @@ error_code sys_semaphore_get_value(ppu_thread& ppu, u32 sem_id, vm::ptr cou return CELL_ESRCH; } + if (!count) + { + return CELL_EFAULT; + } + *count = sema.ret; return CELL_OK; }