From 872be25ed12675267e65d5654105ff5490ae248f Mon Sep 17 00:00:00 2001 From: Eladash Date: Fri, 3 Jan 2020 22:32:17 +0200 Subject: [PATCH] cellFs: Fix cellFsLseek with negative whence --- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 3c745866b9..9b4732174d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -1327,11 +1327,6 @@ error_code sys_fs_lseek(ppu_thread& ppu, u32 fd, s64 offset, s32 whence, vm::ptr sys_fs.trace("sys_fs_lseek(fd=%d, offset=0x%llx, whence=0x%x, pos=*0x%x)", fd, offset, whence, pos); - if (whence >= 3) - { - return {CELL_EINVAL, whence}; - } - const auto file = idm::get(fd); if (!file) @@ -1339,6 +1334,11 @@ error_code sys_fs_lseek(ppu_thread& ppu, u32 fd, s64 offset, s32 whence, vm::ptr return CELL_EBADF; } + if (whence + 0u >= 3) + { + return {CELL_EINVAL, whence}; + } + std::lock_guard lock(file->mp->mutex); const u64 result = file->file.seek(offset, static_cast(whence));