Fix sys_tty_write() if called with pwritelen == NULL.

This commit is contained in:
jjsat 2017-09-03 15:36:58 +02:00 committed by Ivan
parent d4d0d35e05
commit 634c411946
1 changed files with 10 additions and 10 deletions

View File

@ -23,20 +23,20 @@ error_code sys_tty_write(s32 ch, vm::cptr<char> buf, u32 len, vm::ptr<u32> pwrit
{ {
return CELL_EINVAL; return CELL_EINVAL;
} }
const u32 written_len = static_cast<s32>(len) > 0 ? len : 0;
if (static_cast<s32>(len) <= 0) if (written_len > 0 && g_tty)
{
*pwritelen = 0;
return CELL_OK;
}
if (g_tty)
{ {
g_tty.write(buf.get_ptr(), len); g_tty.write(buf.get_ptr(), len);
} }
if (!pwritelen)
{
return CELL_EFAULT;
}
*pwritelen = len; *pwritelen = written_len;
return CELL_OK; return CELL_OK;
} }