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

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