From 634c4119467f3f3db155dc3099a97c46d93f0610 Mon Sep 17 00:00:00 2001 From: jjsat Date: Sun, 3 Sep 2017 15:36:58 +0200 Subject: [PATCH] Fix sys_tty_write() if called with pwritelen == NULL. --- rpcs3/Emu/Cell/lv2/sys_tty.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_tty.cpp b/rpcs3/Emu/Cell/lv2/sys_tty.cpp index e112c32664..dc0626526d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_tty.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_tty.cpp @@ -23,20 +23,20 @@ error_code sys_tty_write(s32 ch, vm::cptr buf, u32 len, vm::ptr pwrit { return CELL_EINVAL; } + + const u32 written_len = static_cast(len) > 0 ? len : 0; - if (static_cast(len) <= 0) - { - *pwritelen = 0; - - return CELL_OK; - } - - if (g_tty) + if (written_len > 0 && g_tty) { g_tty.write(buf.get_ptr(), len); } + + if (!pwritelen) + { + return CELL_EFAULT; + } - *pwritelen = len; - + *pwritelen = written_len; + return CELL_OK; }